open-nomad/ui/app/models/scale-event.js

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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { computed } from '@ember/object';
import Fragment from 'ember-data-model-fragments/fragment';
import { attr } from '@ember-data/model';
import { fragmentOwner } from 'ember-data-model-fragments/attributes';
export default class ScaleEvent extends Fragment {
@fragmentOwner() taskGroupScale;
@attr('number') count;
@attr('number') previousCount;
@attr('boolean') error;
@attr('string') evalId;
2021-12-28 14:45:20 +00:00
@computed('count', function () {
return this.count != null;
})
hasCount;
2021-12-28 14:45:20 +00:00
@computed('count', 'previousCount', function () {
return this.count > this.previousCount;
})
increased;
@attr('date') time;
@attr('number') timeNanos;
@attr('string') message;
@attr() meta;
2021-12-28 14:45:20 +00:00
@computed('meta', function () {
return Object.keys(this.meta).length > 0;
})
hasMeta;
// Since scale events don't have proper IDs, this UID is a compromise
2021-12-28 14:45:20 +00:00
@computed('time', 'timeNanos', 'message', function () {
return `${+this.time}${this.timeNanos}_${this.message}`;
})
uid;
}