Make excluded genres configurable
This commit is contained in:
@@ -21,6 +21,8 @@ config :music_library, default_timezone: "Europe/London"
|
|||||||
|
|
||||||
config :music_library, :similarity, max_distance: 0.45
|
config :music_library, :similarity, max_distance: 0.45
|
||||||
|
|
||||||
|
config :music_library, :excluded_genres, ["rock"]
|
||||||
|
|
||||||
config :music_library, :pagination,
|
config :music_library, :pagination,
|
||||||
default_page_size: 20,
|
default_page_size: 20,
|
||||||
stats_limit: 30,
|
stats_limit: 30,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ defmodule MusicLibrary.Collection do
|
|||||||
alias MusicLibrary.Records.{Record, RecordRelease, SearchIndex}
|
alias MusicLibrary.Records.{Record, RecordRelease, SearchIndex}
|
||||||
alias MusicLibrary.Repo
|
alias MusicLibrary.Repo
|
||||||
|
|
||||||
|
@excluded_genres Application.compile_env!(:music_library, :excluded_genres)
|
||||||
@pagination Application.compile_env!(:music_library, :pagination)
|
@pagination Application.compile_env!(:music_library, :pagination)
|
||||||
|
|
||||||
@spec search_records(String.t(), MusicLibrary.Types.pagination_opts()) :: [SearchIndex.t()]
|
@spec search_records(String.t(), MusicLibrary.Types.pagination_opts()) :: [SearchIndex.t()]
|
||||||
@@ -122,8 +123,7 @@ defmodule MusicLibrary.Collection do
|
|||||||
q =
|
q =
|
||||||
from r in fragment("records, json_each(records.genres)"),
|
from r in fragment("records, json_each(records.genres)"),
|
||||||
where: fragment("records.purchased_at IS NOT NULL"),
|
where: fragment("records.purchased_at IS NOT NULL"),
|
||||||
# we remove rock as it's really generic and dwarfs other genres
|
where: r.value not in @excluded_genres,
|
||||||
where: fragment("? != 'rock'", r.value),
|
|
||||||
group_by: r.value,
|
group_by: r.value,
|
||||||
order_by: [desc: fragment("count(1)")],
|
order_by: [desc: fragment("count(1)")],
|
||||||
select: {r.value, fragment("count(1)")},
|
select: {r.value, fragment("count(1)")},
|
||||||
|
|||||||
Reference in New Issue
Block a user