open-nomad/ui/mirage/serializers/job-version.js
Alex Dadgar e5ec915ac3 sync
2017-09-19 10:08:23 -05:00

26 lines
565 B
JavaScript

import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
serialize() {
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
if (!(json instanceof Array)) {
json = [json];
}
return json
.sortBy('SubmitTime')
.reverse()
.reduce(
(hash, version) => {
hash.Diffs.push(version.Diff);
delete version.Diff;
hash.Versions.push(version);
return hash;
},
{ Versions: [], Diffs: [] }
);
},
});