Skip to content

Commit

Permalink
Merge pull request #3042 from metabrainz/LB-1681
Browse files Browse the repository at this point in the history
LB-1681: Fix 500 error on artist page
  • Loading branch information
MonkeyDo authored Nov 22, 2024
2 parents 20b380f + 7bf4949 commit bcade10
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
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

0 comments on commit bcade10

Please sign in to comment.