Serve artist images via assets
This commit is contained in:
@@ -56,6 +56,19 @@ defmodule MusicLibrary.Artists do
|
||||
q |> Repo.all()
|
||||
end
|
||||
|
||||
def get_image_hashes(lastfm_artists) do
|
||||
musicbrainz_ids = Enum.map(lastfm_artists, & &1.musicbrainz_id)
|
||||
|
||||
q =
|
||||
from ai in ArtistInfo,
|
||||
where: ai.id in ^musicbrainz_ids,
|
||||
select: {ai.id, ai.image_data_hash}
|
||||
|
||||
q
|
||||
|> Repo.all()
|
||||
|> Enum.into(%{})
|
||||
end
|
||||
|
||||
def exists?(artist_id) do
|
||||
q =
|
||||
from ar in ArtistRecord,
|
||||
|
||||
@@ -10,6 +10,7 @@ defmodule MusicLibrary.Search do
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
|
||||
alias MusicLibrary.Artists.ArtistInfo
|
||||
alias MusicLibrary.Records.ArtistRecord
|
||||
alias MusicLibrary.{Collection, Repo, Wishlist}
|
||||
|
||||
@@ -64,10 +65,12 @@ defmodule MusicLibrary.Search do
|
||||
|
||||
q =
|
||||
from ar in ArtistRecord,
|
||||
join: ai in ArtistInfo,
|
||||
on: ar.musicbrainz_id == ai.id,
|
||||
where:
|
||||
fragment("lower(unaccent(artist ->> '$.name')) LIKE ?", ^"%#{normalized_query}%"),
|
||||
group_by: ar.musicbrainz_id,
|
||||
select: ar.artist,
|
||||
select: %{artist: ar.artist, image_data_hash: ai.image_data_hash},
|
||||
limit: ^limit,
|
||||
order_by: fragment("artist ->> '$.name'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user