Use ModifyTime instead of ModifyIndex

This commit is contained in:
Michael Lange 2017-11-30 15:08:31 -08:00
parent 2a69339ef8
commit 54cb23c577
7 changed files with 15 additions and 6 deletions

View file

@ -27,6 +27,7 @@ export default Model.extend({
taskGroupName: attr('string'),
resources: fragment('resources'),
modifyIndex: attr('number'),
modifyTime: attr('date'),
jobVersion: attr('number'),
// TEMPORARY: https://github.com/emberjs/data/issues/5209

View file

@ -35,6 +35,9 @@ export default ApplicationSerializer.extend({
// TEMPORARY: https://github.com/emberjs/data/issues/5209
hash.OriginalJobId = hash.JobID;
hash.ModifyTimeNanos = hash.ModifyTime % 1000000;
hash.ModifyTime = Math.floor(hash.ModifyTime / 1000000);
return this._super(typeHash, hash);
},
});

View file

@ -6,8 +6,8 @@ export default ApplicationSerializer.extend({
// only understand time to the millisecond precision. So store
// the time (precise to ms) as a date, and store the remaining ns
// as a number to deal with when it comes up.
hash.Time = Math.floor(hash.Time / 1000000);
hash.TimeNanos = hash.Time % 1000000;
hash.Time = Math.floor(hash.Time / 1000000);
return this._super(typeHash, hash);
},

View file

@ -3,7 +3,7 @@
{{allocation.shortId}}
{{/link-to}}
</td>
<td>{{allocation.modifyIndex}}</td>
<td>{{moment-format allocation.modifyTime "MM/DD HH:mm:ss"}}</td>
<td>{{allocation.name}}</td>
<td>
<span class="color-swatch {{allocation.clientStatus}}" /> {{allocation.clientStatus}}

View file

@ -5,6 +5,7 @@ import { provide, pickOne } from '../utils';
const UUIDS = provide(100, faker.random.uuid.bind(faker.random));
const CLIENT_STATUSES = ['pending', 'running', 'complete', 'failed', 'lost'];
const DESIRED_STATUSES = ['run', 'stop', 'evict'];
const REF_TIME = new Date();
export default Factory.extend({
id: i => (i >= 100 ? `${UUIDS[i % 100]}-${i}` : UUIDS[i]),
@ -12,6 +13,8 @@ export default Factory.extend({
modifyIndex: () => faker.random.number({ min: 10, max: 2000 }),
jobVersion: () => faker.random.number(10),
modifyTime: () => faker.date.past(2 / 365, REF_TIME) * 1000000,
clientStatus: faker.list.random(...CLIENT_STATUSES),
desiredStatus: faker.list.random(...DESIRED_STATUSES),

View file

@ -3,6 +3,7 @@ import { click, find, findAll, currentURL, visit } from 'ember-native-dom-helper
import { test } from 'qunit';
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import moment from 'moment';
const { $ } = Ember;
@ -127,8 +128,8 @@ test('each allocation should have high-level details for the allocation', functi
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
moment(allocation.modifyTime / 1000000).format('MM/DD HH:mm:ss'),
'Allocation modify time'
);
assert.equal(
allocationRow

View file

@ -3,6 +3,7 @@ import { click, find, findAll, fillIn, currentURL, visit } from 'ember-native-do
import { test } from 'qunit';
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import moment from 'moment';
const { $ } = Ember;
@ -157,8 +158,8 @@ test('each allocation should show basic information about the allocation', funct
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
moment(allocation.modifyTime / 1000000).format('MM/DD HH:mm:ss'),
'Allocation modify time'
);
assert.equal(
allocationRow