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

chroma: Bias toward looking up more relevant releases using date/country #3020

Merged
merged 3 commits into from
Sep 1, 2018

Conversation

Archer4499
Copy link
Contributor

Allow releases from Acoustid lookup to be sorted by date/country
#3017

Uses
match:preferred:countries/original_year:
config options to determine whether the releases should be sorted by their respective fields.
The behaviour is the same as before when the default config is used.
Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good, although I have a few comments inline. And could you please also add a changelog entry?

year = date.get('year', 9999)
month = date.get('month', 99)
day = date.get('day', 99)
key = '{0:04d}{1:02d}{2:02d}'.format(year, month, day)
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason this produces a string instead of a tuple? Python will happily sort tuples indexwise:

>>> sorted([(1,2,3), (1,1,1)])
[(1, 1, 1), (1, 2, 3)]

@@ -88,16 +113,24 @@ def acoustid_match(log, path):
return None
_acoustids[path] = result['id']

# Get recording and releases from the result.
# Get recording and releases from the result,
# sorted by date and/or country depending on 'match'>'preferred' config.
Copy link
Member

Choose a reason for hiding this comment

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

We usually name config options using dot syntax. For example, "the match.preferred configuration option" here. Also, looks like this comment needs to get rewrapped.

for recording in result['recordings']:
recording_ids.append(recording['id'])
if 'releases' in recording:
release_ids += [rel['id'] for rel in recording['releases']]
releases.extend(recording['releases'])
country_patterns = config['match']['preferred']['countries'].as_str_seq()
Copy link
Member

Choose a reason for hiding this comment

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

A comment here might be in order to introduce the reason for all this sorting business.

@sampsyo
Copy link
Member

sampsyo commented Sep 1, 2018

Looks great; thanks!! ✨

@sampsyo sampsyo merged commit e8ffaf9 into beetbox:master Sep 1, 2018
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.

2 participants