UNPKG

@trusthab/composable-resources

Version:

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

34 lines (25 loc) 664 B
const composer = require('../../mixin_loader'); module.exports = (App) => { const { underscore } = require('inflected'); const PROPERTY_VALUE = 'online'; class DevicesOnlineResource { static mixins() { return ['Kpi']; } getMetricId() { return `devices_${PROPERTY_VALUE}`; } getMetricType() { return 'gauge'; } getValue() { const { value } = this.get('diff'); const { device_type } = this.get('obj'); if (value === 'offline' || value === 'unknown' || device_type === 'gateway') { return 0; } return 1; } } return composer(DevicesOnlineResource, App); };