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

SOLR-61: Bring Recording to search parity #40

Merged
merged 12 commits into from Oct 19, 2017

Conversation

samj1912
Copy link
Contributor

@samj1912 samj1912 commented Oct 15, 2017

@samj1912 samj1912 requested review from mayhem and mineo October 15, 2017 09:59
@mayhem
Copy link
Member

mayhem commented Oct 15, 2017

Here as well, having links to see what is going on helps.

@mayhem
Copy link
Member

mayhem commented Oct 15, 2017

This PR is really hard to follow since so many things changed and the ticket also lists a pile of things that are wrong. And the outputs from the two calls in the ticket are also really hard to compare.



def convert_format(obj):
return models.format(id=str(obj.id))
return models.format(valueOf_=obj.name)
Copy link
Contributor Author

@samj1912 samj1912 Oct 15, 2017

Choose a reason for hiding this comment

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

For fixing medium format(format)
See https://musicbrainz.org/ws/2/recording?query=format:CD&limit=1 vs
http://35.193.119.46:8983/solr/recording/select?q=format:CD&rows=1

Expected- 
<format>CD</format>
Result-
<format id="1"/>



def convert_release_status(obj):
"""
:type obj: :class:`mbdata.models.ReleaseStatus`
"""
return models.status(id=str(obj.id))
return models.status(valueOf_=obj.name)
Copy link
Contributor Author

@samj1912 samj1912 Oct 15, 2017

Choose a reason for hiding this comment

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

For fixing release status output(format)
See https://musicbrainz.org/ws/2/recording?query=status:official&limit=1 vs
http://35.193.119.46:8983/solr/recording/select?q=format:CD&rows=1

Expected- 
<status>Official</status>
Result-
<status id="1"/>



def convert_gender(obj):
return models.gender(valueOf_=str(obj.name.lower()))
return models.gender(valueOf_=obj.name.lower())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simply removes the unnecessary str type conversion

@@ -992,19 +1020,19 @@ def convert_release_group_primary_type(obj):
"""
:type obj: :class:`mbdata.models.ReleaseGroupPrimaryType`
"""
return models.primary_type(id=str(obj.id))
return models.primary_type(valueOf_=obj.name)
Copy link
Contributor Author

@samj1912 samj1912 Oct 15, 2017

Choose a reason for hiding this comment

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

Fixes primary type output of a release (pt)

see https://musicbrainz.org/ws/2/recording?query=primarytype:album&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=primarytype:album&rows=1

<primary-type>Album</primary-type>
vs 
<primary-type id="1"/>


for release in recording.release_list.release:
if release.artist_credit == recording.artist_credit:
release.set_artist_credit(None)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -483,7 +509,7 @@ def convert_release_group_for_release(obj):

if obj.type is not None:
rg.set_primary_type(convert_release_group_primary_type(obj.type))
rg.set_type(obj.type.name)
rg.set_type(calculate_type(obj.type, obj.secondary_types))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -445,7 +471,7 @@ def convert_release_from_track(obj):
# same as the recording artist credit, but we've already built it so just
# set it
release.set_artist_credit(convert_artist_credit(rel.artist_credit,
include_aliases=True))
include_aliases=False))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aliases are not needed in the output for related release artist credit

See
https://musicbrainz.org/ws/2/recording?query=reid:0722a81b-dc18-4c19-9d36-fc28cd450a63&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=reid:0722a81b-dc18-4c19-9d36-fc28cd450a63&rows=1

You are looking at the output of artist credit for the release 0722a81b-dc18-4c19-9d36-fc28cd450a63

@@ -50,6 +58,28 @@ def datetime_to_string(obj):
return obj.strftime(TIME_FORMAT)


def calculate_type(primary_type, secondary_types):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

related to fixing label type in the ticket

@@ -128,8 +158,7 @@ def convert_name_credit(obj, include_aliases=True):
"""
:type obj: :class:`mbdata.models.ArtistCreditName`
"""
nc = models.name_credit(name=obj.name,
artist=convert_artist_simple(obj.artist,
nc = models.name_credit(artist=convert_artist_simple(obj.artist,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -325,9 +354,6 @@ def convert_medium(obj):
if obj.format is not None:
m.set_format(convert_format(obj.format))

dl = models.disc_list(count=len(obj.cdtocs))
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 disc list is shown in the current ws output

see
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1

Specifically

<disc-list count="1"/>

is not there in current output so removed it.

Copy link
Member

Choose a reason for hiding this comment

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

This is used by convert_release as well, where http://musicbrainz.org/ws/2/release?query=heino has a disc-list attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have fixed it properly in the PR for release.

@@ -359,7 +385,7 @@ def convert_medium_list(obj):
"""
:type obj: :class:`[mbdata.models.Medium]`
"""
ml = models.medium_list(count=len(obj))
ml = models.medium_list()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Related to label count on the ticket.
Current medium output does not have a count attribute
see
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1

this translates to a bad json output (similar to the tag PR we merged #38 )

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

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

Thank you for explaining these -- looks pretty sane!

@samj1912
Copy link
Contributor Author

Fixed the commits into something more manageable for future git history/ git bisect.

@@ -50,6 +58,28 @@ def datetime_to_string(obj):
return obj.strftime(TIME_FORMAT)


def calculate_type(primary_type, secondary_types):
Copy link
Member

Choose a reason for hiding this comment

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

I'd add lru_cache tu this function because (compared to the amount of recordings) the number of primary / secondary type combinations is very small (and constant).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -325,9 +354,6 @@ def convert_medium(obj):
if obj.format is not None:
m.set_format(convert_format(obj.format))

dl = models.disc_list(count=len(obj.cdtocs))
Copy link
Member

Choose a reason for hiding this comment

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

This is used by convert_release as well, where http://musicbrainz.org/ws/2/release?query=heino has a disc-list attribute.

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