Treat job-summary like a typical relationship rather than a custom link

This way ED doesn't eagerly fetch the job summary even when it's already
in the store due to the jobs list endpoint
This commit is contained in:
Michael Lange
2018-03-20 12:35:32 -07:00
parent 8be0c5a999
commit a6e2f782b7
2 changed files with 16 additions and 5 deletions

View File

@@ -0,0 +1,12 @@
import Watchable from './watchable';
export default Watchable.extend({
urlForFindRecord(id, type, hash) {
const [name, namespace] = JSON.parse(id);
let url = this._super(name, 'job', hash) + '/summary';
if (namespace && namespace !== 'default') {
url += `?namespace=${namespace}`;
}
return url;
},
});

View File

@@ -21,6 +21,10 @@ export default ApplicationSerializer.extend({
hash.ParentID = JSON.stringify([hash.ParentID, hash.NamespaceID || 'default']);
}
// Job Summary is always at /:job-id/summary, but since it can also come from
// the job list, it's better for Ember Data to be linked by ID association.
hash.SummaryID = hash.ID;
// Periodic is a boolean on list and an object on single
if (hash.Periodic instanceof Object) {
hash.PeriodicDetails = hash.Periodic;
@@ -55,11 +59,6 @@ export default ApplicationSerializer.extend({
.split('?');
return assign(this._super(...arguments), {
summary: {
links: {
related: buildURL(`${jobURL}/summary`, { namespace: namespace }),
},
},
allocations: {
links: {
related: buildURL(`${jobURL}/allocations`, { namespace: namespace }),