From 5b37d3c773bd48da41f3cbf20ad22322f28caa6e Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 31 Mar 2026 07:58:02 +0100 Subject: [PATCH] appview/db: add util to get reaction counts Signed-off-by: oppiliappan --- appview/db/reaction.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/appview/db/reaction.go b/appview/db/reaction.go index fda13e5c..287a4324 100644 --- a/appview/db/reaction.go +++ b/appview/db/reaction.go @@ -52,7 +52,16 @@ func DeleteReactionByRkey(e Execer, reactedByDid string, rkey string) error { return err } -func GetReactionCount(e Execer, threadAt syntax.ATURI, kind models.ReactionKind) (int, error) { +func GetReactionCount(e Execer, threadAt syntax.ATURI) (int, error) { + count := 0 + err := e.QueryRow(`select count(reacted_by_did) from reactions where thread_at = ?`, threadAt).Scan(&count) + if err != nil { + return 0, err + } + return count, nil +} + +func GetReactionCountByKind(e Execer, threadAt syntax.ATURI, kind models.ReactionKind) (int, error) { count := 0 err := e.QueryRow( `select count(reacted_by_did) from reactions where thread_at = ? and kind = ?`, threadAt, kind).Scan(&count) -- 2.51.2