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-1419: Fix broken partial dates #3029

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
23 changes: 16 additions & 7 deletions mbid_mapping/mapping/mb_artist_metadata_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,21 @@ def create_json_data(self, row):

release_groups = []
if row["release_groups"]:
for release_group_mbid, release_group_name, artist_credit_name, date, type, secondary_types, release_group_artists, caa_id, caa_release_mbid in row["release_groups"]:
for release_group_mbid, release_group_name, artist_credit_name, year, month, day, type, secondary_types, release_group_artists, caa_id, caa_release_mbid in row["release_groups"]:
release_group = {
"name": release_group_name,
"mbid": release_group_mbid,
"artist_credit_name": artist_credit_name,
"artists": release_group_artists
}
if date is not None:
if year is not None:
date = str(year)
if month is not None:
date += "-%02d" % month
if day is not None:
date += "-%02d" % day
release_group["date"] = date

if type is not None:
release_group["type"] = type
if secondary_types is not None:
Expand Down Expand Up @@ -186,9 +192,9 @@ def get_metadata_cache_query(self, with_values=False):
, ac.name AS artist_credit_name
, rgca.caa_id AS caa_id
, rgca.caa_release_mbid::TEXT AS caa_release_mbid
, (rgm.first_release_date_year::TEXT || '-' ||
LPAD(rgm.first_release_date_month::TEXT, 2, '0') || '-' ||
LPAD(rgm.first_release_date_day::TEXT, 2, '0')) AS date
, rgm.first_release_date_year AS year
, rgm.first_release_date_month AS month
, rgm.first_release_date_day AS day
, rgpt.name AS type
, array_agg(DISTINCT rgst.name ORDER BY rgst.name)
FILTER (WHERE rgst.name IS NOT NULL)
Expand Down Expand Up @@ -246,12 +252,15 @@ def get_metadata_cache_query(self, with_values=False):
rgd.release_group_mbid,
rgd.release_group_name,
rgd.artist_credit_name,
rgd.date,
rgd.year,
rgd.month,
rgd.day,
rgd.type,
rgd.secondary_types,
rgd.release_group_artists,
rgd.caa_id,
rgd.caa_release_mbid
) ORDER BY rgd.date
) ORDER BY rgd.year, rgd.month, rgd.day
)
-- if the artist has no release groups, left join will cause a NULL row to be
-- added to the array, filter ensures that it is removed
Expand Down
15 changes: 11 additions & 4 deletions mbid_mapping/mapping/mb_release_group_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,16 @@ def create_json_data(self, row):
tag["genre_mbid"] = genre_mbid
release_group_tags.append(tag)


date = str(row["year"] or '')
if row["month"] is not None:
mayhem marked this conversation as resolved.
Show resolved Hide resolved
date += "-%02d" % row["month"]
if row["day"] is not None:
date += "-%02d" % row["day"]

release_group = {
"name": row["release_group_name"],
"date": row["date"],
"date": date,
"type": row["type"],
"caa_id": row["caa_id"],
"caa_release_mbid": row["caa_release_mbid"],
Expand Down Expand Up @@ -428,9 +435,9 @@ def get_metadata_cache_query(self, with_values=False):
, rgca.caa_id
, rgca.caa_release_mbid
, rgpt.name AS type
, (rgm.first_release_date_year::TEXT || '-' ||
LPAD(rgm.first_release_date_month::TEXT, 2, '0') || '-' ||
LPAD(rgm.first_release_date_day::TEXT, 2, '0')) AS date
, rgm.first_release_date_year AS year
, rgm.first_release_date_month AS month
, rgm.first_release_date_day AS day
, rec_data.mediums
, rec_data.recordings_release_mbid
FROM musicbrainz.release_group rg
Expand Down