Skip to content

Commit

Permalink
add PUB monthly downloads badge
Browse files Browse the repository at this point in the history
  • Loading branch information
G1Joshi committed Dec 16, 2024
1 parent 5b69244 commit 77d904d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions services/pub/pub-downloads.service.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Joi from 'joi'
import { BaseJsonService, pathParams } from '../index.js'
import { metric } from '../text-formatters.js'
import { renderDownloadsBadge } from '../downloads.js'
import { nonNegativeInteger } from '../validators.js'
import { baseDescription } from './pub-common.js'

const description = `${baseDescription}
<p>This badge shows a measure of how many developers have downloaded a package. This provides a raw measure of the overall sentiment of a package from peer developers.</p>`
<p>This badge shows a measure of how many developers have downloaded a package monthly.</p>`

const schema = Joi.object({
downloadCount30Days: nonNegativeInteger,
Expand All @@ -14,12 +14,12 @@ const schema = Joi.object({
export default class PubDownloads extends BaseJsonService {
static category = 'downloads'

static route = { base: 'pub/downloads', pattern: ':packageName' }
static route = { base: 'pub/dm', pattern: ':packageName' }

static openApi = {
'/pub/downloads/{packageName}': {
'/pub/dm/{packageName}': {
get: {
summary: 'Pub Downloads',
summary: 'Pub Monthly Downloads',
description,
parameters: pathParams({
name: 'packageName',
Expand All @@ -32,11 +32,11 @@ export default class PubDownloads extends BaseJsonService {
static defaultBadgeData = { label: 'downloads' }

static render({ downloadCount30Days }) {
return {
label: 'downloads',
message: metric(downloadCount30Days),
color: 'blue',
}
return renderDownloadsBadge({
downloads: downloadCount30Days,
interval: 'month',
colorOverride: 'blue',
})
}

async fetch({ packageName }) {
Expand Down

0 comments on commit 77d904d

Please sign in to comment.