Improve track refresh logic

This commit is contained in:
Claudio Ortolina
2025-06-02 21:00:44 +01:00
parent 3e9c719ce8
commit 46681deca9
4 changed files with 21 additions and 10 deletions
+6 -5
View File
@@ -28,12 +28,13 @@ defmodule LastFm.Feed do
|> Enum.map(fn t -> Map.take(t, @insertable_fields) end)
|> Enum.map(&Map.to_list/1)
MusicLibrary.Repo.insert_all(LastFm.Track, track_params,
on_conflict: :nothing,
conflict_target: [:scrobbled_at_uts, :title]
)
{count, nil} =
MusicLibrary.Repo.insert_all(LastFm.Track, track_params,
on_conflict: :nothing,
conflict_target: [:scrobbled_at_uts, :title]
)
Phoenix.PubSub.broadcast(LastFm.PubSub, "feed:update", %{tracks: tracks})
Phoenix.PubSub.broadcast(LastFm.PubSub, "feed:update", %{track_count: count})
end
@spec all_tracks(non_neg_integer()) :: [LastFm.Track.t()]