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 bulk low-level get request with non-existent MBID #223

Merged
merged 4 commits into from Mar 7, 2017
Merged

Fix bulk low-level get request with non-existent MBID #223

merged 4 commits into from Mar 7, 2017

Conversation

saifulbkhan
Copy link
Contributor

GET request for bulk low-level data was failing when any single
one of the MBIDs were not present in the database. These entries
are now put into an error field appended to the fetched data for
existing recordings.

Relevant Jira ticket: https://tickets.metabrainz.org/browse/AB-296

GET request for bulk low-level data was failing when any single
one of the MBIDs were not present in the database. These entries
are now put into an error field appended to the fetched data for
existing recordings.
Copy link
Collaborator

@alastair alastair left a comment

Choose a reason for hiding this comment

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

Thanks for the patch.

Can you make sure that you also add a test for this case?

try:
recording_details.setdefault(recording_id, {})[offset] = db.data.load_low_level(recording_id, offset)
except NoDataFoundException:
errors = recording_details.setdefault("errors", {})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've been thinking about this errors key. I don't think it's necessary. My opinion now is that if a recording doesn't exist, we just skip it.

calls = [mock.call("c5f4909e-1d7b-4f15-a6f6-1af376bc01c9", 0),
mock.call("7f27d7a9-27f0-4663-9d20-2c9c40200e6d", 3),
mock.call("405a5ff4-7ee2-436b-95c1-90ce8a83b359", 2)]
load_low_level.assert_has_calls(calls)
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are good mocks!

@alastair
Copy link
Collaborator

alastair commented Mar 5, 2017

This is great, thanks. One thing I missed in the first review is that we need to add to the documentation to say that if data for a recording id doesn't exist, it is silently ignored and will not appear in the returned data.

errors = recording_details.setdefault("errors", {})
mbid_entry = errors.setdefault(recording_id, {})
mbid_entry[offset] = {"message": "recording does not exist"}
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

A small thing on this commit - because you're doing two distinct things, I would have made it as two commits, to make it easier to follow what changes are being made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RIght! I'll seperate the test from this change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You didn't have to make the change again - I was just mentioning it for future work. Thanks for going back and doing it 👍

Add test for low-level bulk GET requests with mbids not present
in database
Remove 'errors' key from result of GET requests.
@alastair alastair merged commit 12c682b into metabrainz:master Mar 7, 2017
@alastair
Copy link
Collaborator

alastair commented Mar 7, 2017

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants