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

Get multiple recordings #209

Merged
merged 3 commits into from Oct 17, 2016
Merged

Get multiple recordings #209

merged 3 commits into from Oct 17, 2016

Conversation

kartikgupta0909
Copy link
Contributor

)

@bp_dataset_eval.route("/bulk-recordings/<recording_ids>", methods=["GET"])
def bulk_recordings(recording_ids):
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to reuse existing endpoint by providing an option to specify list of IDs as an argument. I don't like the trend of creating more and more endpoints that provide multiple ways to get the same data. There should be one place to get a particular entity.

Think about how people are going to use the API, not just a client that you are building. It's hard to change things in the API once they are there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, good idea. This is why I linked this ticket with http://tickets.musicbrainz.org/browse/AB-21 in jira. Let's add this functionality to the standard low-level and high-level endpoints in core.py.

Copy link
Contributor

Choose a reason for hiding this comment

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

So kind of like an existing endpoint, but instead of having ID as a part of URL just have ids argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay will incorporate that into the core API endpoint. @alastair what are your views about putting the recording ids as a part of the url or as a parameter?

@kartikgupta0909
Copy link
Contributor Author

I have updated this PR with the changes suggested in the comments and the ones discussed on the irc.

  1. Now we have a core api endpoint /api/v1/recordings?ids=mbid1:offset1;mbid2:offset2...
  2. The response is of the folllowing format:
    {
    mbid1 :
    {
    offset1: {}
    offset2_for_mbid1 : {}
    }
    }

if len(recordings) > 200:
raise webserver.views.api.exceptions.APIBadRequest("More than 200 recordings not allowed per request")
for recording in recordings:
recording = str(recording).split(":")
Copy link
Contributor

Choose a reason for hiding this comment

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

So specifying an offset is mandatory? I don't think this is a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No its not, Its optional. We are checking first if there are two parameters (id and an offset), if there is no offset we set a default offset of 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, good. I see the comparison below now.

Rename the method and endpoint to refer to low-level, like the
existing GET methods
Catch <0 offsets
If the same request is duplicated in the query, only perform the
request once
also fix embarrassing spelling mistake. valilidate?
@alastair alastair merged commit 0c55517 into master Oct 17, 2016
@alastair
Copy link
Collaborator

This is merged and released!

@alastair alastair deleted the Get-Multiple-Recordings branch January 26, 2018 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants