From 77b81726763679a50b213657f74ef51a43520a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Tue, 1 Jul 2025 15:35:26 +0300 Subject: [PATCH] fix post stats being a cartesian product --- app/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 2657ea9..d7ed94c 100644 --- a/app/models.py +++ b/app/models.py @@ -38,7 +38,7 @@ class Users(Model): def get_post_stats(self): q = """SELECT - COUNT(posts.id) AS post_count, + COUNT(DISTINCT posts.id) AS post_count, COUNT(DISTINCT threads.id) AS thread_count, MAX(threads.title) FILTER (WHERE threads.created_at = latest.created_at) AS latest_thread_title, MAX(threads.slug) FILTER (WHERE threads.created_at = latest.created_at) AS latest_thread_slug