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

Add batchUpsert method to data service case API #680

Merged
merged 8 commits into from
Jul 30, 2020
Merged

Conversation

axmb
Copy link
Contributor

@axmb axmb commented Jul 29, 2020

Primary goal here is to make the bulk upsert MongoDB invocation more efficient.

In pursuit of avoiding a super large/dense PR, I'm cutting this at what's sort of an intermediate state. Rather than expose this endpoint directly in a subsequent PR, I'll probably wrap it together with the existing batchValidate method before doing so (in that same PR). Happy to hear thoughts on this.

@axmb axmb self-assigned this Jul 29, 2020
@axmb axmb marked this pull request as ready for review July 29, 2020 22:32
@axmb axmb requested a review from khmoran July 29, 2020 22:34
Copy link
Contributor

@khmoran khmoran left a comment

Choose a reason for hiding this comment

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

nice!

res: Response,
): Promise<void> => {
try {
const toBeUpsertedCaseIds = await findCaseIdsWithCaseReferenceData(req);
Copy link
Contributor

Choose a reason for hiding this comment

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

if this still isn't as fast as you want, in theory you could have this fn add the ids to the requests, so that below you don't have to re-filter? (assuming that's even an option in mongodb's bulkwrite fn)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meaning to perform the updateOne()'s specifying the _id, rather than the caseRef data pair?

I think that's a solid idea. I'm a little worried about this step being generally slow, but plan to test and make these kinds of tweaks in the subsequent change.

@axmb axmb merged commit 440929e into main Jul 30, 2020
@axmb axmb deleted the mongo-bulk-upsert branch July 30, 2020 16:06
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.

3 participants