From a6e2f782b79bcc7c8b3ce60aa18c83793302012c Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 20 Mar 2018 12:35:32 -0700 Subject: [PATCH] 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 --- ui/app/adapters/job-summary.js | 12 ++++++++++++ ui/app/serializers/job.js | 9 ++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 ui/app/adapters/job-summary.js diff --git a/ui/app/adapters/job-summary.js b/ui/app/adapters/job-summary.js new file mode 100644 index 000000000..e21a54068 --- /dev/null +++ b/ui/app/adapters/job-summary.js @@ -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; + }, +}); diff --git a/ui/app/serializers/job.js b/ui/app/serializers/job.js index d4fad4d67..e57c07e1c 100644 --- a/ui/app/serializers/job.js +++ b/ui/app/serializers/job.js @@ -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 }),