open-nomad/ui/app/models/recommendation.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
781 B
JavaScript
Raw Normal View History

import Model from '@ember-data/model';
import { attr, belongsTo } from '@ember-data/model';
import { get } from '@ember/object';
export default class Recommendation extends Model {
@belongsTo('job') job;
2021-12-28 16:08:12 +00:00
@belongsTo('recommendation-summary', { inverse: 'recommendations' })
recommendationSummary;
@attr('date') submitTime;
get taskGroup() {
return get(this, 'recommendationSummary.taskGroup');
}
@attr('string') taskName;
get task() {
return get(this, 'taskGroup.tasks').findBy('name', this.taskName);
}
@attr('string') resource;
@attr('number') value;
get currentValue() {
2021-12-28 16:08:12 +00:00
const resourceProperty =
this.resource === 'CPU' ? 'reservedCPU' : 'reservedMemory';
return get(this, `task.${resourceProperty}`);
}
@attr() stats;
}