Skip to content

Conversation

@aaxelb
Copy link
Contributor

@aaxelb aaxelb commented Mar 13, 2018

Purpose

Remove as much custom logic from our ember-data classes as possible, and clean up anything left.

Summary of Changes

  • Remove dirty relationship tracking, automatic updates
    • Use built-in relationship serialization instead of making separate requests
    • Use some ugly private API to preserve the only thing of value: Serializing changed relationships only
  • Remove contributor management methods on user model
  • Refactor embed handling
  • Update new project task to create a node with institutions in one request

Side Effects / Testing Notes

No visible changes, at most would require a regression test.

For future development, updating relationships works differently, since they can now be included in a normal POST/PATCH on an object. It should be a little less magic/opaque now.

  • When creating new objects for a relationship, save them separately.
  • When adding existing objects to a relationship, just save the one object. e.g. adding institutions to a node just requires node.save()

Ticket

https://openscience.atlassian.net/browse/EMB-170

Reviewer Checklist

  • meets requirements
  • easy to understand
  • DRY
  • testable and includes test(s)
  • changes described in CHANGELOG.md

@aaxelb aaxelb force-pushed the emb-170--dearchitecting branch from 07b5c72 to 538534e Compare March 13, 2018 22:05
@coveralls
Copy link

coveralls commented Mar 14, 2018

Coverage Status

Coverage remained the same at 22.045% when pulling 0f90bee on aaxelb:emb-170--dearchitecting into 6006989 on CenterForOpenScience:develop.

Copy link
Member

@binoculars binoculars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+:100: for removing cruft. A few minor syntax suggestions.

* @uses GenericDataAdapterMixin
*/
export default class OsfAdapter extends JSONAPIAdapter.extend(GenericDataAdapterMixin, {
export default class OsfAdapter extends JSONAPIAdapter.extend(GenericDataAdapterMixin).extend({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double extend? I haven't seen it before. Maybe add a comment for why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, for some reason I thought that was required for typescript to get the types from the mixin properly, but that's not true. Reverting...

this.get('store').pushPayload(embeddedObj);

// Merge links on the embedded object with links on the relationship, so all returned links are available
const embeddedLinks = Object.assign(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use the object spread operator here.

// Construct a new relationship in JSON API format
if (Array.isArray(embeddedObj.data)) {
relationships[relName] = {
data: embeddedObj.data.map(o => ({ id: o.id, type: o.type })),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaxelb aaxelb force-pushed the emb-170--dearchitecting branch from c9f2243 to 0958e16 Compare March 21, 2018 17:56
@aaxelb aaxelb force-pushed the emb-170--dearchitecting branch from 0958e16 to 08485d9 Compare March 21, 2018 17:58
Copy link
Member

@jamescdavis jamescdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 this is really great!

strict: 0,
indent: 0,
'indent-legacy': 'error',
'function-paren-newline': ['error', 'consistent'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

id: string,
snapshot: Snapshot,
requestType: string,
): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay for readability

$color-bg-blue-dark: #337ab7;
$color-bg-blue-light: #def;
$color-bg-red: #f00;
$color-bg-red: #a00;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this makes a11y happy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the deeper red is more friendly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH #f00 hurt my eyes :)

@jamescdavis jamescdavis merged commit 2f97e1b into CenterForOpenScience:develop Mar 21, 2018
@aaxelb aaxelb deleted the emb-170--dearchitecting branch March 21, 2018 20:32
@jamescdavis jamescdavis added this to the 0.3.0 milestone May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants