github.com/manicqin/nomad@v0.9.5/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    services: fragmentArray('service'),
    18  
    19    drivers: computed('tasks.@each.driver', function() {
    20      return this.tasks.mapBy('driver').uniq();
    21    }),
    22  
    23    allocations: computed('job.allocations.@each.taskGroup', function() {
    24      return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.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.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.name);
    44    }),
    45  });