Add shortId properties to reschedule events model

This commit is contained in:
Michael Lange 2018-05-02 11:21:01 -07:00
parent d66ecd3402
commit c2d860955f
2 changed files with 9 additions and 7 deletions

View File

@ -1,12 +1,16 @@
import Fragment from 'ember-data-model-fragments/fragment'; import Fragment from 'ember-data-model-fragments/fragment';
import attr from 'ember-data/attr'; import attr from 'ember-data/attr';
import { fragmentOwner } from 'ember-data-model-fragments/attributes'; import { fragmentOwner } from 'ember-data-model-fragments/attributes';
import shortUUIDProperty from '../utils/properties/short-uuid';
export default Fragment.extend({ export default Fragment.extend({
allocation: fragmentOwner(), allocation: fragmentOwner(),
previousAllocationID: attr('string'), previousAllocationId: attr('string'),
previousNodeID: attr('string'), previousNodeId: attr('string'),
time: attr('date'), time: attr('date'),
delay: attr('string'), delay: attr('string'),
previousAllocationShortId: shortUUIDProperty('previousAllocationId'),
previousNodeShortId: shortUUIDProperty('previousNodeShortId'),
}); });

View File

@ -1,11 +1,6 @@
import ApplicationSerializer from './application'; import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({ export default ApplicationSerializer.extend({
attrs: {
previousAllocationID: 'PrevAllocID',
previousNodeID: 'PrevNodeID',
},
normalize(typeHash, hash) { normalize(typeHash, hash) {
// Time is in the form of nanoseconds since epoch, but JS dates // Time is in the form of nanoseconds since epoch, but JS dates
// only understand time to the millisecond precision. So store // only understand time to the millisecond precision. So store
@ -14,6 +9,9 @@ export default ApplicationSerializer.extend({
hash.TimeNanos = hash.RescheduleTime % 1000000; hash.TimeNanos = hash.RescheduleTime % 1000000;
hash.Time = Math.floor(hash.RescheduleTime / 1000000); hash.Time = Math.floor(hash.RescheduleTime / 1000000);
hash.PreviousAllocationId = hash.PrevAllocID ? hash.PrevAllocID : null;
hash.PreviousNodeId = hash.PrevNodeID ? hash.PrevNodeID : null;
return this._super(typeHash, hash); return this._super(typeHash, hash);
}, },
}); });