2018-02-08 23:02:48 +00:00
|
|
|
import { collect, sum } from '@ember/object/computed';
|
|
|
|
import Model from 'ember-data/model';
|
|
|
|
import attr from 'ember-data/attr';
|
|
|
|
import { belongsTo } from 'ember-data/relationships';
|
|
|
|
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
|
|
|
import sumAggregation from '../utils/properties/sum-aggregation';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class JobSummary extends Model {
|
|
|
|
@belongsTo('job') job;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@fragmentArray('task-group-summary') taskGroupSummaries;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
|
|
|
// Aggregate allocation counts across all summaries
|
2020-06-10 13:49:16 +00:00
|
|
|
@sumAggregation('taskGroupSummaries', 'queuedAllocs') queuedAllocs;
|
|
|
|
@sumAggregation('taskGroupSummaries', 'startingAllocs') startingAllocs;
|
|
|
|
@sumAggregation('taskGroupSummaries', 'runningAllocs') runningAllocs;
|
|
|
|
@sumAggregation('taskGroupSummaries', 'completeAllocs') completeAllocs;
|
|
|
|
@sumAggregation('taskGroupSummaries', 'failedAllocs') failedAllocs;
|
|
|
|
@sumAggregation('taskGroupSummaries', 'lostAllocs') lostAllocs;
|
|
|
|
|
|
|
|
@collect(
|
2018-02-08 23:02:48 +00:00
|
|
|
'queuedAllocs',
|
|
|
|
'startingAllocs',
|
|
|
|
'runningAllocs',
|
|
|
|
'completeAllocs',
|
|
|
|
'failedAllocs',
|
|
|
|
'lostAllocs'
|
2020-06-10 13:49:16 +00:00
|
|
|
)
|
|
|
|
allocsList;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@sum('allocsList') totalAllocs;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr('number') pendingChildren;
|
|
|
|
@attr('number') runningChildren;
|
|
|
|
@attr('number') deadChildren;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@collect('pendingChildren', 'runningChildren', 'deadChildren') childrenList;
|
2018-02-08 23:02:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@sum('childrenList') totalChildren;
|
|
|
|
}
|