Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix n+1 problem for zoom account availability #82

Merged
merged 9 commits into from
Jun 9, 2020

Conversation

prabalsingh24
Copy link
Contributor

fixes #18

@prabalsingh24 prabalsingh24 force-pushed the zoom-account-n+1 branch 2 times, most recently from a2b6ade to ea4ff45 Compare May 21, 2020 19:13
@thenamankumar
Copy link
Contributor

@prabalsingh24 you need to add separate loader for Resource.availability.

Comment on lines 12 to 18
loaders: {
zoomAccountAvailabilityLoader: ZoomAccount.getAvailabilityLoader(),
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

or do you mean to add a different loader here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

zoomAccountResourceLoader something like this?

api/services/ZoomAccount/index.js Outdated Show resolved Hide resolved
api/graphql/query/Resource/availability.js Outdated Show resolved Hide resolved
},
...utilizedResourceClause(args.dateTimeRange, args.options),
}).then((accounts) =>
keys.map((key) => !accounts.find((account) => key.id === account.id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

can't compare just based on id. Need to do deep equate for the whole key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

key : {
  id: 28,
  dateTimeRange: {
    start_at: '2020-05-20T18:30:00.000Z',
    end_at: '2020-05-20T19:30:00.000Z'
  }
}
zoomAccount : {
    id: 28,
    email: '[email protected]',
    created_at: 2020-05-21T06:45:50.203Z,
    updated_at: 2020-05-21T06:45:50.203Z

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we can do deep equate here?

Copy link
Contributor

Choose a reason for hiding this comment

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

You also get ZoomAccount.resource having start_at and end_at. Form the same shape with the data from db and then equate them.

api/services/ZoomAccount/index.js Outdated Show resolved Hide resolved
api/services/ZoomAccount/index.js Outdated Show resolved Hide resolved
Comment on lines 23 to 28
ifAvailableDuring(dateTimeRange, options) {
return ZoomAccount.findAvailaibilityDuring(
this.instance.id,
dateTimeRange,
options,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change this.

@thenamankumar
Copy link
Contributor

Please update your branch with master.

@prabalsingh24
Copy link
Contributor Author

I have few doubts. I've replied in above comments :)

api/services/ZoomAccount/index.js Outdated Show resolved Hide resolved
api/services/ZoomAccount/index.js Outdated Show resolved Hide resolved
},
...utilizedResourceClause(args.dateTimeRange, args.options),
}).then((accounts) =>
keys.map((key) => !accounts.find((account) => key.id === account.id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

You also get ZoomAccount.resource having start_at and end_at. Form the same shape with the data from db and then equate them.

@thenamankumar
Copy link
Contributor

@prabalsingh24 what is the status on this?

@prabalsingh24
Copy link
Contributor Author

@prabalsingh24 what is the status on this?

Sir can we discuss this over a call once?

@prabalsingh24
Copy link
Contributor Author

I've made the changes and it is working too. Have a look whenever you're free :)

Sorry I was little slow in doing this, I had my end semester exams

);
};

equateKeyAndInvite({ id, excludedEvents = [], dateTimeRange }, account) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not equating key to invite here. Fix the name.

@thenamankumar
Copy link
Contributor

Looks good. Just minor change request.

@thenamankumar thenamankumar merged commit f923413 into coding-blocks:master Jun 9, 2020
@boss-contributions-bot
Copy link

Congratualtions @prabalsingh24, your pull request is merged! 🎉

Thanks for your contributions and participating in BOSS 2020. 🙌

You can claim your bounty points here. 💰

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.

[ZoomAccounts] Fix N+1 issue in availability field
2 participants