mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
fix TG_OP
This commit is contained in:
parent
7162c13fac
commit
c17be517af
1 changed files with 7 additions and 7 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue