musikr.graph: avoid bad melding of nonmbid verts

This commit is contained in:
Alexander Capehart
2025-08-15 11:42:25 -06:00
parent 2be5fb28d6
commit bd42d69538
@@ -255,7 +255,9 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
}
// second pass: cluster artists by mbid and identify invalid ones
// (i.e artists with the same mbid but different metadata)
val mbidClusters = artistVertices.values.groupBy { it.preArtist.musicBrainzId }
// this only applies to artists w/mbids, if we dont do this well meld all non-mbid
// artists into a single vertex which is incorrect
val mbidClusters = artistVertices.values.groupBy { it.preArtist.musicBrainzId }.filter { it.key != null }
for (cluster in mbidClusters.values) {
// everything in the cluster must have the same pre-artist
val canon = cluster.maxBy { it.songVertices.size }.preArtist
@@ -278,7 +280,9 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
}
// second pass: cluster albums by mbid and identify invalid ones
// (i.e albums with the same mbid but different metadata)
val mbidAlbumClusters = albumVertices.values.groupBy { it.preAlbum.musicBrainzId }
// this only applies to albums w/mbids, if we dont do this well meld all non-mbid
// albums into a single vertex which is incorrect
val mbidAlbumClusters = albumVertices.values.groupBy { it.preAlbum.musicBrainzId }.filter { it.key != null }
for (cluster in mbidAlbumClusters.values) {
// everything in the cluster must have the same pre-album
val canon = cluster.maxBy { it.songVertices.size }.preAlbum