2017-12-15 21:39:18 +00:00
|
|
|
import { computed } from '@ember/object';
|
2017-09-19 14:47:10 +00:00
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
import attr from 'ember-data/attr';
|
|
|
|
import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes';
|
|
|
|
import sumAggregation from '../utils/properties/sum-aggregation';
|
|
|
|
|
2018-02-08 23:02:48 +00:00
|
|
|
const maybe = arr => arr || [];
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
export default Fragment.extend({
|
|
|
|
job: fragmentOwner(),
|
|
|
|
|
|
|
|
name: attr('string'),
|
|
|
|
count: attr('number'),
|
|
|
|
|
|
|
|
tasks: fragmentArray('task'),
|
|
|
|
|
2018-05-10 00:04:45 +00:00
|
|
|
drivers: computed('tasks.@each.driver', function() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return this.tasks
|
2018-05-10 00:04:45 +00:00
|
|
|
.mapBy('driver')
|
|
|
|
.uniq();
|
|
|
|
}),
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
allocations: computed('job.allocations.@each.taskGroup', function() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.name);
|
2017-09-19 14:47:10 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
reservedCPU: sumAggregation('tasks', 'reservedCPU'),
|
|
|
|
reservedMemory: sumAggregation('tasks', 'reservedMemory'),
|
|
|
|
reservedDisk: sumAggregation('tasks', 'reservedDisk'),
|
|
|
|
|
|
|
|
reservedEphemeralDisk: attr('number'),
|
|
|
|
|
2017-11-29 01:23:30 +00:00
|
|
|
placementFailures: computed('job.latestFailureEvaluation.failedTGAllocs.[]', function() {
|
|
|
|
const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs');
|
2019-03-26 07:46:44 +00:00
|
|
|
return placementFailures && placementFailures.findBy('name', this.name);
|
2017-11-29 01:23:30 +00:00
|
|
|
}),
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
queuedOrStartingAllocs: computed('summary.{queuedAllocs,startingAllocs}', function() {
|
|
|
|
return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs');
|
|
|
|
}),
|
|
|
|
|
|
|
|
summary: computed('job.taskGroupSummaries.[]', function() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.name);
|
2017-09-19 14:47:10 +00:00
|
|
|
}),
|
|
|
|
});
|