Remove unused LastFm.Feed functions
This commit is contained in:
@@ -37,40 +37,6 @@ defmodule LastFm.Feed do
|
|||||||
:ets.select_reverse(__MODULE__, m)
|
:ets.select_reverse(__MODULE__, m)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec all_artists() :: [LastFm.Artist.t()]
|
|
||||||
def all_artists do
|
|
||||||
m = [
|
|
||||||
{
|
|
||||||
{:"$1", %{scrobbled_at_label: :"$2", artist: :"$3"}},
|
|
||||||
[],
|
|
||||||
[%{scrobbled_at_uts: :"$1", scrobbled_at_label: :"$2", artist: :"$3"}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
:ets.select_reverse(__MODULE__, m) |> Enum.uniq_by(fn pair -> pair.artist end)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec all_albums() :: [LastFm.Album.t()]
|
|
||||||
def all_albums do
|
|
||||||
m = [
|
|
||||||
{
|
|
||||||
{:"$1", %{scrobbled_at_label: :"$2", album: :"$3", cover_url: :"$4", artist: :"$5"}},
|
|
||||||
[],
|
|
||||||
[
|
|
||||||
%{
|
|
||||||
scrobbled_at_uts: :"$1",
|
|
||||||
scrobbled_at_label: :"$2",
|
|
||||||
album: :"$3",
|
|
||||||
cover_url: :"$4",
|
|
||||||
artist: :"$5"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
:ets.select_reverse(__MODULE__, m) |> Enum.uniq_by(fn pair -> pair.album end)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec subscribe() :: :ok
|
@spec subscribe() :: :ok
|
||||||
def subscribe do
|
def subscribe do
|
||||||
Phoenix.PubSub.subscribe(LastFm.PubSub, "feed:update")
|
Phoenix.PubSub.subscribe(LastFm.PubSub, "feed:update")
|
||||||
|
|||||||
@@ -46,32 +46,5 @@ defmodule LastFm.FeedTest do
|
|||||||
:ok = Feed.update([@track_two, @track_one])
|
:ok = Feed.update([@track_two, @track_one])
|
||||||
assert [@track_two, @track_one] == Feed.all_tracks()
|
assert [@track_two, @track_one] == Feed.all_tracks()
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns artists in descending order of scrobble" do
|
|
||||||
:ok = Feed.update([@track_two, @track_one])
|
|
||||||
|
|
||||||
assert [
|
|
||||||
%{
|
|
||||||
artist: @track_two.artist,
|
|
||||||
scrobbled_at_uts: @track_two.scrobbled_at_uts,
|
|
||||||
scrobbled_at_label: @track_two.scrobbled_at_label
|
|
||||||
}
|
|
||||||
] ==
|
|
||||||
Feed.all_artists()
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it returns albums in descending order of scrobble" do
|
|
||||||
:ok = Feed.update([@track_two, @track_one])
|
|
||||||
|
|
||||||
assert [
|
|
||||||
%{
|
|
||||||
artist: @track_two.artist,
|
|
||||||
album: @track_two.album,
|
|
||||||
cover_url: @track_two.cover_url,
|
|
||||||
scrobbled_at_uts: @track_two.scrobbled_at_uts,
|
|
||||||
scrobbled_at_label: @track_two.scrobbled_at_label
|
|
||||||
}
|
|
||||||
] == Feed.all_albums()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user