In scrobble activitiy, prioritize matchin on collected release first
When the collection contains multiple records for the same release group, we want the scrobble activity to first match against the one that was actually scrobbled, as opposed to ANY other collected release.
This commit is contained in:
@@ -126,7 +126,8 @@ defmodule MusicLibrary.Collection do
|
||||
select: %{
|
||||
record_id: fragment("records.id"),
|
||||
cover_hash: fragment("records.cover_hash"),
|
||||
release_id: r.value
|
||||
release_id: r.value,
|
||||
selected_release_id: fragment("records.selected_release_id")
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -190,7 +190,9 @@ defmodule MusicLibrary.ScrobbleActivity do
|
||||
tracks_query =
|
||||
from t in Track,
|
||||
left_join: cr in subquery(Collection.collected_releases_query()),
|
||||
on: cr.release_id == fragment("? ->> '$.musicbrainz_id'", t.album),
|
||||
on:
|
||||
cr.selected_release_id == fragment("? ->> '$.musicbrainz_id'", t.album) or
|
||||
cr.release_id == fragment("? ->> '$.musicbrainz_id'", t.album),
|
||||
left_join: wr in subquery(Wishlist.wishlisted_releases_query()),
|
||||
on: wr.release_id == fragment("? ->> '$.musicbrainz_id'", t.album),
|
||||
left_join: ar in subquery(all_artists_query),
|
||||
|
||||
Reference in New Issue
Block a user