Fix timezone definition and handling across app

This commit is contained in:
Claudio Ortolina
2025-09-11 16:17:20 +03:00
parent 5aaa7708ee
commit c67fd27ea1
5 changed files with 9 additions and 21 deletions
+2 -7
View File
@@ -214,7 +214,7 @@ defmodule MusicLibrary.ScrobbleActivity do
def get_top_albums_by_days(days, opts) do
limit = Keyword.get(opts, :limit, 10)
current_time = Keyword.get_lazy(opts, :current_time, &DateTime.utc_now/0)
timezone = Keyword.get(opts, :timezone, &resolve_timezone!/0)
timezone = Keyword.get(opts, :timezone, &MusicLibrary.timezone/0)
cutoff_timestamp =
current_time
@@ -304,7 +304,7 @@ defmodule MusicLibrary.ScrobbleActivity do
def get_top_artists_by_days(days, opts) do
limit = Keyword.get(opts, :limit, 10)
current_time = Keyword.get_lazy(opts, :current_time, &DateTime.utc_now/0)
timezone = Keyword.get(opts, :timezone, &resolve_timezone!/0)
timezone = Keyword.get(opts, :timezone, &MusicLibrary.timezone/0)
cutoff_timestamp =
current_time
@@ -376,9 +376,4 @@ defmodule MusicLibrary.ScrobbleActivity do
:last_365_days -> get_top_artists_by_days(365, opts)
end
end
defp resolve_timezone! do
Application.get_env(:music_library, MusicLibraryWeb)
|> Keyword.fetch!(:timezone)
end
end