fix TG_OP

This commit is contained in:
dullbananas 2023-12-28 19:40:48 -07:00 committed by GitHub
parent 7162c13fac
commit c17be517af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,7 @@ END
$$; $$;
-- Selects both old and new rows in a trigger and allows using `sum(count_diff)` to get the number to add to a count -- Selects both old and new rows in a trigger and allows using `sum(count_diff)` to get the number to add to a count
CREATE FUNCTION r.combine_transition_tables () CREATE FUNCTION r.combine_transition_tables (tg_op text)
RETURNS SETOF record RETURNS SETOF record
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
@ -148,7 +148,7 @@ BEGIN
sum(count_diff) FILTER (WHERE (thing_like).score = 1) AS upvotes, sum(count_diff) FILTER (WHERE (thing_like).score = 1) AS upvotes,
sum(count_diff) FILTER (WHERE (thing_like).score != 1) AS downvotes sum(count_diff) FILTER (WHERE (thing_like).score != 1) AS downvotes
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, AS (count_diff bigint,
thing_like thing_like) thing_like thing_like)
GROUP BY GROUP BY
@ -198,7 +198,7 @@ BEGIN
(comment).local, (comment).local,
sum(count_diff) AS comments sum(count_diff) AS comments
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, AS (count_diff bigint,
comment comment) comment comment)
WHERE WHERE
@ -301,7 +301,7 @@ BEGIN
(post).local, (post).local,
sum(count_diff) AS posts sum(count_diff) AS posts
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, AS (count_diff bigint,
post post) post post)
WHERE WHERE
@ -357,7 +357,7 @@ BEGIN
SELECT SELECT
sum(count_diff) AS communities sum(count_diff) AS communities
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, community community) AS (count_diff bigint, community community)
WHERE (community).local AND NOT ((community).deleted OR (community).removed)) AS diff; WHERE (community).local AND NOT ((community).deleted OR (community).removed)) AS diff;
RETURN NULL; RETURN NULL;
@ -379,7 +379,7 @@ BEGIN
SELECT SELECT
sum(count_diff) AS users sum(count_diff) AS users
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, person person) AS (count_diff bigint, person person)
WHERE (person).local) AS diff; WHERE (person).local) AS diff;
RETURN NULL; RETURN NULL;
@ -450,7 +450,7 @@ BEGIN
(community_follower).community_id, (community_follower).community_id,
sum(count_diff) AS subscribers sum(count_diff) AS subscribers
FROM FROM
r.combine_transition_tables () r.combine_transition_tables (TG_OP)
AS (count_diff bigint, community_follower community_follower) AS (count_diff bigint, community_follower community_follower)
WHERE ( WHERE (
SELECT SELECT