This commit is contained in:
Dull Bananas 2023-12-25 16:43:32 +00:00
parent 22abe64959
commit fb95056b2c
2 changed files with 14 additions and 20 deletions

View file

@ -2,4 +2,4 @@
nogrouping=1 nogrouping=1
# Don't add whitespace around % (used for `format`) in dollar-quoted function body # Don't add whitespace around % (used for `format`) in dollar-quoted function body
placeholder=[^\s;]+%[^\s;]+ placeholder=[a-zA-Z0-9_\\.]*%[a-zA-Z0-9_\\.]*

View file

@ -215,8 +215,7 @@ BEGIN
AS $$ AS $$
BEGIN BEGIN
-- Update aggregates for target, then update aggregates for target's creator -- Update aggregates for target, then update aggregates for target's creator
WITH WITH target_diff (
target_diff (
creator_id, score creator_id, score
) AS ( UPDATE ) AS ( UPDATE
%1$s_aggregates AS target_aggregates %1$s_aggregates AS target_aggregates
@ -233,15 +232,10 @@ BEGIN
UPDATE UPDATE
person_aggregates person_aggregates
SET SET
%1$s_score = %1$s_score + diff.score %1$s_score = %1$s_score + diff.score FROM (
FROM (
SELECT SELECT
creator_id, creator_id, sum(score)
sum(score) FROM target_diff GROUP BY creator_id) AS diff
FROM
target_diff
GROUP BY
creator_id) AS diff
WHERE WHERE
person_aggregates.person_id = diff.creator_id; person_aggregates.person_id = diff.creator_id;
RETURN NULL; RETURN NULL;