Move sorting to db query

This commit is contained in:
Claudio Ortolina
2024-11-01 19:04:40 +00:00
parent 893890a2e9
commit 4c57f47bca
3 changed files with 5 additions and 7 deletions
+2
View File
@@ -67,6 +67,7 @@ defmodule MusicLibrary.Records do
from r in Record,
where: not is_nil(r.purchased_at),
group_by: r.format,
order_by: [desc: count(r.id)],
select: {r.format, count(r.id)}
Repo.all(q)
@@ -77,6 +78,7 @@ defmodule MusicLibrary.Records do
from r in Record,
where: not is_nil(r.purchased_at),
group_by: r.type,
order_by: [desc: count(r.id)],
select: {r.type, count(r.id)}
Repo.all(q)