Files
shields/services/symfony/symfony-insight-grade.service.js
Caleb Cartwright a4bd3f5fd6 Add SymfonyInsight stars badge, run [SymfonyInsight sensiolabs amo chrome-web-store redmine spigetratings vaadin-directory visualstudiomarketplacerating wordpress] (#2971)
* feat: added stars badge for symfony insight

* refactor: changed symfony star determination logic

* feat: updating symfony to handle old scan scenarios

* feat: updated symfony insight to handle older projects

* tests: removed another test for symfony insight per request
2019-02-20 17:15:31 -06:00

58 lines
1.1 KiB
JavaScript

'use strict'
const {
SymfonyInsightBase,
keywords,
gradeColors,
} = require('./symfony-insight-base')
module.exports = class SymfonyInsightGrade extends SymfonyInsightBase {
static render({ status, grade }) {
const label = 'grade'
if (status !== 'finished' && status !== '') {
return {
label,
message: 'pending',
color: 'lightgrey',
}
}
const message = grade === 'none' ? 'no medal' : grade
return {
label,
message,
color: gradeColors[grade],
}
}
static get route() {
return {
base: 'symfony/i/grade',
pattern: ':projectUuid',
}
}
static get examples() {
return [
{
title: 'SymfonyInsight Grade',
namedParams: {
projectUuid: '45afb680-d4e6-4e66-93ea-bcfa79eb8a87',
},
staticPreview: this.render({
grade: 'bronze',
status: 'finished',
}),
keywords,
},
]
}
async handle({ projectUuid }) {
const data = await this.fetch({ projectUuid })
const { grade, status } = this.transform({ data })
return this.constructor.render({ grade, status })
}
}