This moves a few helpers from `lib/` to `services/`: build-status.js build-status.spec.js color-formatters.js color-formatters.spec.js contributor-count.js licenses.js licenses.spec.js php-version.js php-version.spec.js text-formatters.js text-formatters.spec.js version.js version.spec.js And one from `lib/` to `core/`: unhandled-rejection.spec.js The diff is long, but the changes are straightforward. Ref #2832
47 lines
887 B
JavaScript
47 lines
887 B
JavaScript
'use strict'
|
|
|
|
const { metric } = require('../text-formatters')
|
|
const { BaseAmoService, keywords } = require('./amo-base')
|
|
|
|
module.exports = class AmoUsers extends BaseAmoService {
|
|
static get category() {
|
|
return 'downloads'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'amo/users',
|
|
pattern: ':addonId',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Mozilla Add-on',
|
|
namedParams: { addonId: 'dustman' },
|
|
staticPreview: this.render({ users: 750 }),
|
|
keywords,
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return {
|
|
label: 'users',
|
|
}
|
|
}
|
|
|
|
static render({ users }) {
|
|
return {
|
|
message: metric(users),
|
|
color: 'blue',
|
|
}
|
|
}
|
|
|
|
async handle({ addonId }) {
|
|
const data = await this.fetch({ addonId })
|
|
return this.constructor.render({ users: data.average_daily_users })
|
|
}
|
|
}
|