* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Autofixes
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const {
|
|
coveragePercentage: coveragePercentageColor,
|
|
} = require('../color-formatters')
|
|
const { BasePuppetForgeModulesService } = require('./puppetforge-base')
|
|
const { NotFound } = require('..')
|
|
|
|
module.exports = class PuppetforgeModuleFeedback extends BasePuppetForgeModulesService {
|
|
static get category() {
|
|
return 'rating'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'puppetforge/f',
|
|
pattern: ':user/:moduleName',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Puppet Forge feedback score',
|
|
namedParams: {
|
|
user: 'camptocamp',
|
|
moduleName: 'openssl',
|
|
},
|
|
staticPreview: this.render({ score: 61 }),
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'score' }
|
|
}
|
|
|
|
static render({ score }) {
|
|
return {
|
|
message: `${score}%`,
|
|
color: coveragePercentageColor(score),
|
|
}
|
|
}
|
|
|
|
async handle({ user, moduleName }) {
|
|
const data = await this.fetch({ user, moduleName })
|
|
if (data.feedback_score == null) {
|
|
throw new NotFound({ prettyMessage: 'unknown' })
|
|
}
|
|
return this.constructor.render({ score: data.feedback_score })
|
|
}
|
|
}
|