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