github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/models/job-summary.js (about) 1 import { collect, sum } from '@ember/object/computed'; 2 import Model from 'ember-data/model'; 3 import attr from 'ember-data/attr'; 4 import { belongsTo } from 'ember-data/relationships'; 5 import { fragmentArray } from 'ember-data-model-fragments/attributes'; 6 import sumAggregation from '../utils/properties/sum-aggregation'; 7 8 export default Model.extend({ 9 job: belongsTo('job'), 10 11 taskGroupSummaries: fragmentArray('task-group-summary'), 12 13 // Aggregate allocation counts across all summaries 14 queuedAllocs: sumAggregation('taskGroupSummaries', 'queuedAllocs'), 15 startingAllocs: sumAggregation('taskGroupSummaries', 'startingAllocs'), 16 runningAllocs: sumAggregation('taskGroupSummaries', 'runningAllocs'), 17 completeAllocs: sumAggregation('taskGroupSummaries', 'completeAllocs'), 18 failedAllocs: sumAggregation('taskGroupSummaries', 'failedAllocs'), 19 lostAllocs: sumAggregation('taskGroupSummaries', 'lostAllocs'), 20 21 allocsList: collect( 22 'queuedAllocs', 23 'startingAllocs', 24 'runningAllocs', 25 'completeAllocs', 26 'failedAllocs', 27 'lostAllocs' 28 ), 29 30 totalAllocs: sum('allocsList'), 31 32 pendingChildren: attr('number'), 33 runningChildren: attr('number'), 34 deadChildren: attr('number'), 35 36 childrenList: collect('pendingChildren', 'runningChildren', 'deadChildren'), 37 38 totalChildren: sum('childrenList'), 39 });