fix: add missing GROUP BY clause to rants_of_user and posts_of_user views

The rants_of_user and posts_of_user views were missing a GROUP BY clause on the username column, causing the GROUP_CONCAT aggregations to produce incorrect concatenated results across all rows instead of per-user groupings. This fix adds the required GROUP BY username to both view definitions, ensuring each user's rants and comments are properly aggregated into separate rows.
This commit is contained in:
retoor 2024-12-03 03:21:25 +00:00
parent 3c2b2e192a
commit 13bcd5d6af

View File

@ -199,11 +199,11 @@ def get_db():
)
db.query("DROP VIEW IF EXISTS rants_of_user")
db.query(
"CREATE VIEW rants_of_user as SELECT user_username as username, GROUP_CONCAT(text) as text FROM rants"
"CREATE VIEW rants_of_user as SELECT user_username as username, GROUP_CONCAT(text) as text FROM rants GROUP BY username"
)
db.query("DROP VIEW IF EXISTS posts_of_user")
db.query(
"CREATE VIEW posts_of_user AS SELECT user_username as username, GROUP_CONCAT(body) as text FROM comments"
"CREATE VIEW posts_of_user AS SELECT user_username as username, GROUP_CONCAT(body) as text FROM comments GROUP BY username"
)
db.query("DROP VIEW IF EXISTS contributions_extended_ranked")
db.query(