mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
Now that blocking queries are going to be in play, We can no longer pretend the two requests are one, since they have independent nomad indices.
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
import { get } from '@ember/object';
|
|
import ApplicationSerializer from './application';
|
|
|
|
export default ApplicationSerializer.extend({
|
|
normalize(modelClass, hash) {
|
|
// Transform the map-based Summary object into an array-based
|
|
// TaskGroupSummary fragment list
|
|
hash.PlainJobId = hash.JobID;
|
|
hash.ID = JSON.stringify([hash.JobID, hash.Namespace || 'default']);
|
|
|
|
hash.TaskGroupSummaries = Object.keys(get(hash, 'Summary') || {}).map(key => {
|
|
const allocStats = get(hash, `Summary.${key}`) || {};
|
|
const summary = { Name: key };
|
|
|
|
Object.keys(allocStats).forEach(
|
|
allocKey => (summary[`${allocKey}Allocs`] = allocStats[allocKey])
|
|
);
|
|
|
|
return summary;
|
|
});
|
|
|
|
// Lift the children stats out of the Children object
|
|
const childrenStats = get(hash, 'Children');
|
|
if (childrenStats) {
|
|
Object.keys(childrenStats).forEach(
|
|
childrenKey => (hash[`${childrenKey}Children`] = childrenStats[childrenKey])
|
|
);
|
|
}
|
|
|
|
return this._super(modelClass, hash);
|
|
},
|
|
});
|