fix post stats being a cartesian product

This commit is contained in:
Lera Elvoé 2025-07-01 15:35:26 +03:00
parent 04a59c8396
commit 77b8172676
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc

View File

@ -38,7 +38,7 @@ class Users(Model):
def get_post_stats(self): def get_post_stats(self):
q = """SELECT q = """SELECT
COUNT(posts.id) AS post_count, COUNT(DISTINCT posts.id) AS post_count,
COUNT(DISTINCT threads.id) AS thread_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.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 MAX(threads.slug) FILTER (WHERE threads.created_at = latest.created_at) AS latest_thread_slug