First pass at having a chat count in the entity pages

This commit is contained in:
Claudio Ortolina
2026-03-19 12:28:58 +00:00
parent 2ba8aef148
commit 1001610472
6 changed files with 68 additions and 2 deletions
+8
View File
@@ -25,6 +25,14 @@ defmodule MusicLibrary.Chats do
|> Repo.all()
end
@spec count_chats(atom(), String.t()) :: non_neg_integer()
def count_chats(entity, musicbrainz_id) do
from(c in Chat,
where: c.entity == ^entity and c.musicbrainz_id == ^musicbrainz_id
)
|> Repo.aggregate(:count)
end
@spec has_any_chats?(atom(), String.t()) :: boolean()
def has_any_chats?(entity, musicbrainz_id) do
from(c in Chat,