Add "On this day" section to stats

This commit is contained in:
Claudio Ortolina
2025-08-29 12:20:46 +03:00
parent a0a71b3a47
commit f47cbc77f5
6 changed files with 128 additions and 2 deletions
+13
View File
@@ -40,6 +40,19 @@ defmodule MusicLibrary.Collection do
Repo.all(q)
end
def get_records_on_this_day(date \\ Date.utc_today()) do
month_day = Calendar.strftime(date, "%m-%d")
q =
from r in Record,
where: not is_nil(r.purchased_at),
where: fragment("strftime('%m-%d', ?) = ?", r.release_date, ^month_day),
order_by: [desc: r.release_date],
select: ^Records.essential_fields()
Repo.all(q)
end
def get_latest_record! do
q =
from r in Record,