Add LastFm.Feed.all_artists/0 and LastFm.Feed.all_albums/0

This commit is contained in:
Claudio Ortolina
2024-12-10 14:57:28 +03:00
parent a6e1e4e34a
commit c2ccb7dde2
2 changed files with 36 additions and 0 deletions
+26
View File
@@ -37,6 +37,32 @@ defmodule LastFm.Feed do
:ets.select_reverse(__MODULE__, m)
end
@spec all_artists() :: [LastFm.Artist.t()]
def all_artists do
m = [
{
{:"$1", %{artist: :"$2"}},
[],
[:"$2"]
}
]
:ets.select_reverse(__MODULE__, m) |> Enum.uniq()
end
@spec all_albums() :: [LastFm.Album.t()]
def all_albums do
m = [
{
{:"$1", %{album: :"$2"}},
[],
[:"$2"]
}
]
:ets.select_reverse(__MODULE__, m) |> Enum.uniq()
end
@spec subscribe() :: :ok
def subscribe do
Phoenix.PubSub.subscribe(LastFm.PubSub, "feed:update")