Files
shields/services/amo/amo-users.service.js
Paul Melnikow 7c226456fe Adopt static fields in [amo] and core (#5440)
Since we've upgraded production to Node 12 (#5436) we can finally adopt static fields!

This starts the process by updating core and one of the service families.
2020-08-19 14:49:29 -04:00

33 lines
760 B
JavaScript

'use strict'
const { metric } = require('../text-formatters')
const { BaseAmoService, keywords } = require('./amo-base')
module.exports = class AmoUsers extends BaseAmoService {
static category = 'downloads'
static route = { base: 'amo/users', pattern: ':addonId' }
static examples = [
{
title: 'Mozilla Add-on',
namedParams: { addonId: 'dustman' },
staticPreview: this.render({ users: 750 }),
keywords,
},
]
static defaultBadgeData = { 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 })
}
}