From 2ceff3a1e99ecb1c3f5bd41ab6a444ff4de92756 Mon Sep 17 00:00:00 2001 From: Jared Galanis Date: Thu, 27 Jun 2024 06:45:26 -0400 Subject: [PATCH] refactor: remove non strict and non explicit relationships deprecation (#1268) * refactor: update deprecation workflow list * refactor: fix non-strict and non-explicit relationships --- app/deprecation-workflow.js | 2 -- app/models/deposit.js | 6 +++--- app/models/file.js | 2 +- app/models/funder.js | 2 +- app/models/grant.js | 8 ++++---- app/models/policy.js | 2 +- app/models/publication.js | 3 +-- app/models/repository-copy.js | 4 ++-- app/models/submission-event.js | 4 ++-- app/models/submission.js | 12 +++++++----- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/deprecation-workflow.js b/app/deprecation-workflow.js index 5b46a359e..0f8fdf12e 100644 --- a/app/deprecation-workflow.js +++ b/app/deprecation-workflow.js @@ -2,8 +2,6 @@ import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; setupDeprecationWorkflow({ workflow: [ - { handler: 'silence', matchId: 'ember-simple-auth.initializer.setup-session-restoration' }, - { handler: 'silence', matchId: 'ember-data:deprecate-non-strict-relationships' }, { handler: 'silence', matchId: 'ember-data:deprecate-early-static' }, { handler: 'silence', matchId: 'ensure-safe-component.string' }, { handler: 'silence', matchId: 'routing.transition-methods' }, diff --git a/app/models/deposit.js b/app/models/deposit.js index 2db3fd6f4..a0fc767e3 100644 --- a/app/models/deposit.js +++ b/app/models/deposit.js @@ -4,9 +4,9 @@ export default class DepositModel extends Model { @attr('string') depositStatusRef; @attr('string') depositStatus; - @belongsTo('repositoryCopy') repositoryCopy; - @belongsTo('submission') submission; - @belongsTo('repository') repository; + @belongsTo('repositoryCopy', { async: false, inverse: null }) repositoryCopy; + @belongsTo('submission', { async: false, inverse: null }) submission; + @belongsTo('repository', { async: false, inverse: null }) repository; } export const DepositStatus = { diff --git a/app/models/file.js b/app/models/file.js index 766434acb..e29179f16 100644 --- a/app/models/file.js +++ b/app/models/file.js @@ -8,7 +8,7 @@ export default class FileModel extends Model { @attr('string') uri; @attr('string') mimeType; - @belongsTo('submission') submission; + @belongsTo('submission', { async: false, inverse: null }) submission; // not represented on backend // @attr('string') _file; diff --git a/app/models/funder.js b/app/models/funder.js index 933f75d5a..68fcddb9d 100644 --- a/app/models/funder.js +++ b/app/models/funder.js @@ -5,5 +5,5 @@ export default class FunderModel extends Model { @attr('string') url; @attr('string') localKey; - @belongsTo('policy') policy; + @belongsTo('policy', { async: false, inverse: null }) policy; } diff --git a/app/models/grant.js b/app/models/grant.js index c116336f2..b96cc3c08 100644 --- a/app/models/grant.js +++ b/app/models/grant.js @@ -12,8 +12,8 @@ export default class GrantModel extends Model { /** Date the grant ended */ @attr('date') endDate; - @belongsTo('user') pi; - @hasMany('user') coPis; - @belongsTo('funder') primaryFunder; - @belongsTo('funder') directFunder; + @belongsTo('user', { async: false, inverse: null }) pi; + @hasMany('user', { async: false, inverse: null }) coPis; + @belongsTo('funder', { async: true, inverse: null }) primaryFunder; + @belongsTo('funder', { async: false, inverse: null }) directFunder; } diff --git a/app/models/policy.js b/app/models/policy.js index f1395489c..34ceda443 100644 --- a/app/models/policy.js +++ b/app/models/policy.js @@ -5,7 +5,7 @@ export default class PolicyModel extends Model { @attr('string') description; @attr('string') policyUrl; - @hasMany('repository') repositories; + @hasMany('repository', { async: false, inverse: null }) repositories; @attr('string') institution; @attr('string') _type; diff --git a/app/models/publication.js b/app/models/publication.js index 1ab4ef581..2d0cd1fae 100644 --- a/app/models/publication.js +++ b/app/models/publication.js @@ -9,8 +9,7 @@ export default class PublicationModel extends Model { @attr('string') issue; @attr('string') pmid; - @belongsTo('journal', { autoSave: true }) journal; - // submissions: DS.hasMany('submission', { async: true }) + @belongsTo('journal', { async: false, inverse: null, autoSave: true }) journal; get abstract() { return this.publicationAbstract; } diff --git a/app/models/repository-copy.js b/app/models/repository-copy.js index 220b05098..47eb76cf2 100644 --- a/app/models/repository-copy.js +++ b/app/models/repository-copy.js @@ -5,8 +5,8 @@ export default class RepositoryCopyModel extends Model { @attr('string') accessUrl; @attr('string') copyStatus; - @belongsTo('publication') publication; - @belongsTo('repository') repository; + @belongsTo('publication', { async: false, inverse: null }) publication; + @belongsTo('repository', { async: false, inverse: null }) repository; } export const CopyStatus = { diff --git a/app/models/submission-event.js b/app/models/submission-event.js index d345266ec..7620600af 100644 --- a/app/models/submission-event.js +++ b/app/models/submission-event.js @@ -7,8 +7,8 @@ export default class SubmissionEventModel extends Model { @attr('string') comment; @attr('string') link; - @belongsTo('submission') submission; - @belongsTo('user') performedBy; + @belongsTo('submission', { async: true, inverse: '_submissionEvents' }) submission; + @belongsTo('user', { async: false, inverse: null }) performedBy; } export const Type = { diff --git a/app/models/submission.js b/app/models/submission.js index 84d20d46d..fd6c4a7c6 100644 --- a/app/models/submission.js +++ b/app/models/submission.js @@ -20,15 +20,16 @@ export default class SubmissionModel extends Model { submitterEmail; @attr('number') version; - @belongsTo('user') submitter; - @belongsTo('publication') publication; + @belongsTo('user', { async: false, inverse: null }) submitter; + @belongsTo('publication', { async: false, inverse: null }) publication; - @hasMany('user') preparers; - @hasMany('repository') repositories; - @hasMany('policy') effectivePolicies; + @hasMany('user', { async: false, inverse: null }) preparers; + @hasMany('repository', { async: true, inverse: null }) repositories; + @hasMany('policy', { async: false, inverse: null }) effectivePolicies; // not on this model on API @hasMany('submissionEvent', { async: true, + inverse: 'submission', }) _submissionEvents; /** @@ -38,6 +39,7 @@ export default class SubmissionModel extends Model { */ @hasMany('grant', { async: true, + inverse: null, }) grants;