2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2018-02-08 23:02:48 +00:00
|
|
|
import { collect, sum } from '@ember/object/computed';
|
2021-02-17 21:01:44 +00:00
|
|
|
import Model from '@ember-data/model';
|
|
|
|
import { attr, belongsTo } from '@ember-data/model';
|
2018-02-08 23:02:48 +00:00
|
|
|
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;
|
2022-04-22 15:25:02 +00:00
|
|
|
@sumAggregation('taskGroupSummaries', 'unknownAllocs') unknownAllocs;
|
2020-06-10 13:49:16 +00:00
|
|
|
@sumAggregation('taskGroupSummaries', 'lostAllocs') lostAllocs;
|
|
|
|
|
|
|
|
@collect(
|
2018-02-08 23:02:48 +00:00
|
|
|
'queuedAllocs',
|
|
|
|
'startingAllocs',
|
|
|
|
'runningAllocs',
|
|
|
|
'completeAllocs',
|
|
|
|
'failedAllocs',
|
2022-04-22 15:25:02 +00:00
|
|
|
'lostAllocs',
|
|
|
|
'unknownAllocs'
|
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;
|
|
|
|
}
|