github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/models/task-group.js (about) 1 import { computed } from '@ember/object'; 2 import Fragment from 'ember-data-model-fragments/fragment'; 3 import attr from 'ember-data/attr'; 4 import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes'; 5 import sumAggregation from '../utils/properties/sum-aggregation'; 6 7 const maybe = arr => arr || []; 8 9 export default Fragment.extend({ 10 job: fragmentOwner(), 11 12 name: attr('string'), 13 count: attr('number'), 14 15 tasks: fragmentArray('task'), 16 17 drivers: computed('tasks.@each.driver', function() { 18 return this.get('tasks') 19 .mapBy('driver') 20 .uniq(); 21 }), 22 23 allocations: computed('job.allocations.@each.taskGroup', function() { 24 return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.get('name')); 25 }), 26 27 reservedCPU: sumAggregation('tasks', 'reservedCPU'), 28 reservedMemory: sumAggregation('tasks', 'reservedMemory'), 29 reservedDisk: sumAggregation('tasks', 'reservedDisk'), 30 31 reservedEphemeralDisk: attr('number'), 32 33 placementFailures: computed('job.latestFailureEvaluation.failedTGAllocs.[]', function() { 34 const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs'); 35 return placementFailures && placementFailures.findBy('name', this.get('name')); 36 }), 37 38 queuedOrStartingAllocs: computed('summary.{queuedAllocs,startingAllocs}', function() { 39 return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs'); 40 }), 41 42 summary: computed('job.taskGroupSummaries.[]', function() { 43 return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.get('name')); 44 }), 45 });