UNPKG

@trusthab/composable-resources

Version:

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

34 lines (24 loc) 676 B
const composer = require('../../mixin_loader'); module.exports = (App) => { const { underscore } = require('inflected'); const PROPERTY_VALUE = 'canceled'; class AlertsCanceledResource { static mixins() { return ['Kpi']; } getMetricId() { return 'alerts_canceled'; } getMetricType() { return 'gauge'; } getValue() { const { archived } = this.get('obj'); const { value, oldValue } = this.get('diff'); if (archived === 'true') { return 0; } if (oldValue !== PROPERTY_VALUE && value === PROPERTY_VALUE) { return 1; } return 0; } } return composer(AlertsCanceledResource, App); };