Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/warning if download count is low #305

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading