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-1681: Fix 500 error on artist page #3042

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions listenbrainz/webserver/views/entity_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ def get_release_group_sort_key(release_group):
if release_date is None:
release_date = datetime.min
else:
# Add default month/day if missing
parts = release_date.split('-')
if len(parts) == 1: # YYYY
release_date += "-01-01"
elif len(parts) == 2: # YYYY-MM
release_date += "-01"

release_date = datetime.strptime(release_date, "%Y-%m-%d")

return release_group["total_listen_count"] or 0, release_date
Expand Down
4 changes: 2 additions & 2 deletions mbid_mapping/mapping/mb_artist_metadata_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def create_json_data(self, row):
date = str(year)
if month is not None:
date += "-%02d" % month
if day is not None:
date += "-%02d" % day
if day is not None:
date += "-%02d" % day
release_group["date"] = date

if type is not None:
Expand Down
12 changes: 7 additions & 5 deletions mbid_mapping/mapping/mb_release_group_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ def create_json_data(self, row):
release_group_tags.append(tag)


date = str(row["year"] or '')
if row["month"] is not None:
date += "-%02d" % row["month"]
if row["day"] is not None:
date += "-%02d" % row["day"]
date = ''
if row["year"] is not None:
date = str(row["year"])
if row["month"] is not None:
date += "-%02d" % row["month"]
if row["day"] is not None:
date += "-%02d" % row["day"]

release_group = {
"name": row["release_group_name"],
Expand Down