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

LB-1495: lb-radio endpoint is affected by letter case #2815

Closed
wants to merge 3 commits into from

Conversation

ericd23
Copy link
Contributor

@ericd23 ericd23 commented Mar 18, 2024

Problem

Basically, upper case tag won't do anything. For example: https://api.listenbrainz.org/1/lb-radio/tags?tag=Jazz&begin_percent=0&end_percent=50&count=50 gives 0 results. It's because PG's WHERE clause is case-sensitive.

Solution

Convert all tags into lower case when loading the query params. Also add a integration test for this endpoint.

@pep8speaks
Copy link

pep8speaks commented Mar 18, 2024

Hello @ericd23! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-03-18 03:01:51 UTC

@@ -722,6 +722,7 @@ def get_tags_dataset():
tag = request.args.getlist("tag")
if tag is None:
raise APIBadRequest("tag param is missing")
tag = [t.lower() for t in tag]
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if all tag names in the database are lower cased. I'll check if that is the case, then the fix would work. If not, a case insensitive match should be performed in the SQL query. Will update.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping @amCap1712

Copy link
Member

Choose a reason for hiding this comment

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

It appears that all tags are in fact lowercase:

musicbrainz_db=# select count(distinct(lower(name))) from tag;
 count  
--------
 213811
(1 row)

musicbrainz_db=# select count(*) from tag;
 count  
--------
 213811
(1 row)

@mayhem
Copy link
Member

mayhem commented Apr 23, 2024

I feel that this isn't a problem that should be fixed in ListenBrainz, its a troi problem. I've fixed this in troi, so closing this PR. Thanks for submitting the PR, much appreciated!

@mayhem mayhem closed this Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants