UNPKG

@trusthab/composable-resources

Version:

migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable

35 lines (24 loc) 665 B
const composer = require('../../mixin_loader'); const { isUndefined } = require('lodash'); module.exports = (App) => { const { underscore } = require('inflected'); class AlertsTotalResource { static mixins() { return ['Kpi']; } getMetricId() { return 'alerts_total'; } getMetricType() { return 'counter'; } getValue() { const { archived } = this.get('obj'); const { value, oldValue } = this.get('diff'); if (archived === 'true') { return 0; } if (isUndefined(oldValue) && !isUndefined(value)) { return 1; } return 0; } } return composer(AlertsTotalResource, App); };