Improve track refresh logic
This commit is contained in:
+6
-5
@@ -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()]
|
||||
|
||||
Reference in New Issue
Block a user