* convert [homebrew,hsts,itunes,jenkins,jetbrains] classes to static props * Run the prettier across the files * Updated the correct values in logos.spec.js * revert back the logos.spec.js changes * Completed refactoring of [lgtm liberapay librariesio localizely luarocks] * Convert defaultBadgeData to object Co-authored-by: Jabbar Memon <jabbar@zoop.one>
48 lines
950 B
JavaScript
48 lines
950 B
JavaScript
'use strict'
|
|
|
|
const { metric } = require('../text-formatters')
|
|
const LgtmBaseService = require('./lgtm-base')
|
|
|
|
module.exports = class LgtmAlerts extends LgtmBaseService {
|
|
static route = {
|
|
base: 'lgtm/alerts',
|
|
pattern: this.pattern,
|
|
}
|
|
|
|
static examples = [
|
|
{
|
|
title: 'LGTM Alerts',
|
|
namedParams: {
|
|
host: 'github',
|
|
user: 'apache',
|
|
repo: 'cloudstack',
|
|
},
|
|
staticPreview: this.render({ alerts: 2488 }),
|
|
},
|
|
]
|
|
|
|
static defaultBadgeData = {
|
|
label: 'lgtm alerts',
|
|
}
|
|
|
|
static getColor({ alerts }) {
|
|
let color = 'yellow'
|
|
if (alerts === 0) {
|
|
color = 'brightgreen'
|
|
}
|
|
return color
|
|
}
|
|
|
|
static render({ alerts }) {
|
|
return {
|
|
message: metric(alerts),
|
|
color: this.getColor({ alerts }),
|
|
}
|
|
}
|
|
|
|
async handle({ host, user, repo }) {
|
|
const { alerts } = await this.fetch({ host, user, repo })
|
|
return this.constructor.render({ alerts })
|
|
}
|
|
}
|