Skip to content

Commit

Permalink
feat/warning if download count is low (#305)
Browse files Browse the repository at this point in the history
* feat: new warning if download count is low
  • Loading branch information
lirantal authored Mar 4, 2024
1 parent 6a3f090 commit 81d1d85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/marshalls/author.marshall.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Marshall extends BaseMarshall {
// get date in ms
const currentDate = new Date()
const dateDiffInMsVersionPublished = currentDate - new Date(versionPublishedDateString)
console.log(dateDiffInMsVersionPublished)
let dateDiffVersionPublished = 0
if (dateDiffInMsVersionPublished > 0) {
dateDiffVersionPublished = Math.round(dateDiffInMsVersionPublished / (1000 * 60 * 60 * 24))
Expand Down
10 changes: 9 additions & 1 deletion lib/marshalls/downloads.marshall.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict'

const BaseMarshall = require('./baseMarshall')
const Warning = require('../helpers/warning')
const { marshallCategories } = require('./constants')

const MARSHALL_NAME = 'downloads'
const DOWNLOAD_COUNT_THRESHOLD = 20 // threshold per month
const DOWNLOAD_COUNT_THRESHOLD = 100 // threshold per month
const DOWNLOAD_COUNT_UPPER_THRESHOLD = 10000 // threshold per month

class Marshall extends BaseMarshall {
constructor(options) {
Expand All @@ -25,6 +27,12 @@ class Marshall extends BaseMarshall {
)
}

if (downloadCount < DOWNLOAD_COUNT_UPPER_THRESHOLD) {
throw new Warning(
`detected a low relatively low download-count package (${downloadCount} downloads last month)`
)
}

return downloadCount
})
}
Expand Down

0 comments on commit 81d1d85

Please sign in to comment.