mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
Update replaceable_schema.sql
This commit is contained in:
parent
94b745fd69
commit
d2dc15330d
1 changed files with 16 additions and 6 deletions
|
@ -259,7 +259,7 @@ BEGIN
|
||||||
-- Update aggregates for target
|
-- Update aggregates for target
|
||||||
target_aggregates_update_result (creator_id, creator_score_change) AS (
|
target_aggregates_update_result (creator_id, creator_score_change) AS (
|
||||||
UPDATE
|
UPDATE
|
||||||
%1$s_aggregates AS aggregates
|
%1$s_aggregates AS target_aggregates
|
||||||
SET
|
SET
|
||||||
score = score + added_upvotes - added_downvotes,
|
score = score + added_upvotes - added_downvotes,
|
||||||
upvotes = upvotes + added_upvotes,
|
upvotes = upvotes + added_upvotes,
|
||||||
|
@ -271,10 +271,20 @@ BEGIN
|
||||||
FROM
|
FROM
|
||||||
vote_group
|
vote_group
|
||||||
WHERE
|
WHERE
|
||||||
aggregates.comment_id = vote_group.target_id
|
target_aggregates.comment_id = vote_group.target_id
|
||||||
RETURNING
|
RETURNING
|
||||||
%2$s,
|
%2$s,
|
||||||
added_upvotes - added_downvotes;
|
added_upvotes - added_downvotes
|
||||||
|
)
|
||||||
|
-- Update aggregates for target's creator
|
||||||
|
UPDATE
|
||||||
|
person_aggregates
|
||||||
|
SET
|
||||||
|
%1$s_score = creator_score_change;
|
||||||
|
FROM
|
||||||
|
target_aggregates_update_result
|
||||||
|
WHERE
|
||||||
|
person_aggregates.person_id = creator_id;
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END
|
END
|
||||||
|
@ -291,9 +301,9 @@ BEGIN
|
||||||
END
|
END
|
||||||
$a$;
|
$a$;
|
||||||
|
|
||||||
CALL aggregates_from_like ('comment', '(SELECT creator_id FROM comment WHERE id = vote_group.target_id)');
|
CALL aggregates_from_like ('comment', '(SELECT creator_id FROM comment WHERE id = vote_group.target_id LIMIT 1)');
|
||||||
|
|
||||||
CALL aggregates_from_like ('post', 'creator_id');
|
CALL aggregates_from_like ('post', 'target_aggregates.creator_id');
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue