diff --git a/lib/last_fm.ex b/lib/last_fm.ex index df36bd52..5f6e460d 100644 --- a/lib/last_fm.ex +++ b/lib/last_fm.ex @@ -2,8 +2,6 @@ defmodule LastFm do alias LastFm.{API, Feed, Refresh, Scrobble, Track, Worker} alias MusicLibrary.{BackgroundRepo, Repo} - def get_scrobbled_tracks(limit \\ 100), do: Feed.all_tracks(limit) - def subscribe_to_feed, do: Feed.subscribe() def refresh_scrobbled_tracks, do: Refresh.refresh() diff --git a/lib/last_fm/feed.ex b/lib/last_fm/feed.ex index 28825f69..65815c7d 100644 --- a/lib/last_fm/feed.ex +++ b/lib/last_fm/feed.ex @@ -8,8 +8,6 @@ defmodule LastFm.Feed do to one track at a time, and the timestamp has second-level precision. """ - import Ecto.Query - @insertable_fields [ :musicbrainz_id, :title, @@ -44,16 +42,6 @@ defmodule LastFm.Feed do {:ok, count} end - @spec all_tracks(non_neg_integer()) :: [LastFm.Track.t()] - def all_tracks(limit) do - q = - from t in LastFm.Track, - order_by: {:desc, t.scrobbled_at_uts}, - limit: ^limit - - MusicLibrary.Repo.all(q) - end - @spec subscribe() :: :ok def subscribe do Phoenix.PubSub.subscribe(LastFm.PubSub, "feed:update") diff --git a/lib/music_library/collection.ex b/lib/music_library/collection.ex index 1e5dcc0a..d7edb060 100644 --- a/lib/music_library/collection.ex +++ b/lib/music_library/collection.ex @@ -75,16 +75,6 @@ defmodule MusicLibrary.Collection do Repo.one!(q) end - def collected_releases(release_ids) do - q = - from r in fragment("records, json_each(records.release_ids)"), - where: r.value in ^release_ids, - where: fragment("records.purchased_at IS NOT NULL"), - select: %{record_id: fragment("records.id"), release_id: r.value} - - Repo.all(q) - end - def count_records_by_artist(opts \\ []) do limit = Keyword.get(opts, :limit, 30) diff --git a/lib/music_library/wishlist.ex b/lib/music_library/wishlist.ex index 38f4d275..959ab675 100644 --- a/lib/music_library/wishlist.ex +++ b/lib/music_library/wishlist.ex @@ -21,16 +21,6 @@ defmodule MusicLibrary.Wishlist do Repo.aggregate(base_search(), :count) end - def wishlisted_releases(release_ids) do - q = - from r in fragment("records, json_each(records.release_ids)"), - where: r.value in ^release_ids, - where: fragment("records.purchased_at IS NULL"), - select: %{record_id: fragment("records.id"), release_id: r.value} - - Repo.all(q) - end - defp base_search do from r in SearchIndex, where: is_nil(r.purchased_at) diff --git a/test/last_fm/feed_test.exs b/test/last_fm/feed_test.exs index 2a56520a..aa90cecb 100644 --- a/test/last_fm/feed_test.exs +++ b/test/last_fm/feed_test.exs @@ -47,16 +47,5 @@ defmodule LastFm.FeedTest do assert {:ok, 0} == Feed.update([@track_two, @track_one]) assert_receive %{track_count: 0} end - - test "it returns tracks in descending order of scrobble" do - assert {:ok, 2} == Feed.update([@track_two, @track_one]) - track_two_scrobbled_at_uts = @track_two.scrobbled_at_uts - track_one_scrobbled_at_uts = @track_one.scrobbled_at_uts - - assert [ - %{scrobbled_at_uts: ^track_two_scrobbled_at_uts}, - %{scrobbled_at_uts: ^track_one_scrobbled_at_uts} - ] = Feed.all_tracks(10) - end end end