fix post stats being a cartesian product
This commit is contained in:
parent
04a59c8396
commit
77b8172676
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user