Skip to content

Commit

Permalink
refactor: fix non-strict and non-explicit relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredgalanis committed May 25, 2024
1 parent 153a939 commit c52502b
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 23 deletions.
2 changes: 0 additions & 2 deletions app/deprecation-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
6 changes: 3 additions & 3 deletions app/models/deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion app/models/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/models/funder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 4 additions & 4 deletions app/models/grant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion app/models/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions app/models/publication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions app/models/repository-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions app/models/submission-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 7 additions & 5 deletions app/models/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -38,6 +39,7 @@ export default class SubmissionModel extends Model {
*/
@hasMany('grant', {
async: true,
inverse: null,
})
grants;

Expand Down

0 comments on commit c52502b

Please sign in to comment.