Unify order of more services (#3358)

Ref #3353
This commit is contained in:
Paul Melnikow
2019-04-24 15:08:26 -04:00
committed by GitHub
parent 1dd8d1329c
commit f8aeb56129
76 changed files with 1298 additions and 1308 deletions

View File

@@ -23,6 +23,17 @@ const periodMap = {
}
module.exports = class JitpackDownloads extends BaseJsonService {
static get category() {
return 'downloads'
}
static get route() {
return {
base: 'jitpack',
pattern: ':period(dw|dm)/:vcs(github|bitbucket|gitlab)/:user/:repo',
}
}
static get examples() {
return [
{
@@ -42,29 +53,17 @@ module.exports = class JitpackDownloads extends BaseJsonService {
]
}
static get category() {
return 'downloads'
}
static get defaultBadgeData() {
return { label: 'downloads' }
}
static get route() {
static render({ downloads, period }) {
return {
base: 'jitpack',
pattern: ':period(dw|dm)/:vcs(github|bitbucket|gitlab)/:user/:repo',
message: `${metric(downloads)}${periodMap[period].suffix}`,
color: downloadCount(downloads),
}
}
async handle({ period, vcs, user, repo }) {
const json = await this.fetch({ vcs, user, repo })
return this.constructor.render({
downloads: json[periodMap[period].api_field],
period,
})
}
async fetch({ vcs, user, repo }) {
return this._requestJson({
schema,
@@ -73,10 +72,11 @@ module.exports = class JitpackDownloads extends BaseJsonService {
})
}
static render({ downloads, period }) {
return {
message: `${metric(downloads)}${periodMap[period].suffix}`,
color: downloadCount(downloads),
}
async handle({ period, vcs, user, repo }) {
const json = await this.fetch({ vcs, user, repo })
return this.constructor.render({
downloads: json[periodMap[period].api_field],
period,
})
}
}