Skip to content

Commit

Permalink
Merge pull request #2999 from metabrainz/ansh/fix-artist-metadata
Browse files Browse the repository at this point in the history
fix: Release Group Artist Credits are duplicated
  • Loading branch information
MonkeyDo authored Nov 19, 2024
2 parents b1f879e + 15b0ff1 commit 44f7929
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mbid_mapping/mapping/mb_artist_metadata_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_json_data(self, row):
"name": release_group_name,
"mbid": release_group_mbid,
"artist_credit_name": artist_credit_name,
"artists": release_group_artists
"artists": sorted(release_group_artists, key=lambda x: x.pop("position", float('inf')))
}
if year is not None:
date = str(year)
Expand Down Expand Up @@ -199,11 +199,12 @@ def get_metadata_cache_query(self, with_values=False):
, array_agg(DISTINCT rgst.name ORDER BY rgst.name)
FILTER (WHERE rgst.name IS NOT NULL)
AS secondary_types
, jsonb_agg(jsonb_build_object(
, jsonb_agg(DISTINCT jsonb_build_object(
'artist_mbid', a2.gid::TEXT,
'artist_credit_name', acn2.name,
'join_phrase', acn2.join_phrase
) ORDER BY acn2.position) AS release_group_artists
'join_phrase', acn2.join_phrase,
'position', acn2.position
)) AS release_group_artists
FROM musicbrainz.artist a
JOIN musicbrainz.artist_credit_name acn
ON a.id = acn.artist
Expand Down Expand Up @@ -427,3 +428,4 @@ def create_mb_artist_metadata_cache(use_lb_conn: bool):
def incremental_update_mb_artist_metadata_cache(use_lb_conn: bool):
""" Update the MB metadata cache incrementally """
incremental_update_metadata_cache(MusicBrainzArtistMetadataCache, MB_ARTIST_METADATA_CACHE_TIMESTAMP_KEY, use_lb_conn)

0 comments on commit 44f7929

Please sign in to comment.