github.com/emate/nomad@v0.8.2-wo-binpacking/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    allocations: computed('job.allocations.@each.taskGroup', function() {
    18      return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.get('name'));
    19    }),
    20  
    21    reservedCPU: sumAggregation('tasks', 'reservedCPU'),
    22    reservedMemory: sumAggregation('tasks', 'reservedMemory'),
    23    reservedDisk: sumAggregation('tasks', 'reservedDisk'),
    24  
    25    reservedEphemeralDisk: attr('number'),
    26  
    27    placementFailures: computed('job.latestFailureEvaluation.failedTGAllocs.[]', function() {
    28      const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs');
    29      return placementFailures && placementFailures.findBy('name', this.get('name'));
    30    }),
    31  
    32    queuedOrStartingAllocs: computed('summary.{queuedAllocs,startingAllocs}', function() {
    33      return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs');
    34    }),
    35  
    36    summary: computed('job.taskGroupSummaries.[]', function() {
    37      return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.get('name'));
    38    }),
    39  });