File tree Expand file tree Collapse file tree 13 files changed +126
-126
lines changed
crates/diesel_utils/replaceable_schema
2020-06-30-135809_remove_mat_views
2020-08-03-000110_add_preferred_usernames_banners_and_icons
2021-01-27-202728_active_users_monthly
2021-08-16-004209_fix_remove_bots_from_aggregates
2023-12-06-180359_edit_active_users
2024-11-12-090437_move-triggers Expand file tree Collapse file tree 13 files changed +126
-126
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ CREATE OR REPLACE FUNCTION r.community_aggregates_activity (i text)
159159 LANGUAGE plpgsql
160160 AS $$
161161BEGIN
162- RETURN query
162+ RETURN QUERY
163163 SELECT
164164 count (* )::integer ,
165165 community_id
@@ -174,33 +174,33 @@ BEGIN
174174 WHERE
175175 c .published_at > (' now' ::timestamp - i::interval)
176176 AND pe .bot_account = FALSE
177- UNION
178- SELECT
179- p .creator_id ,
180- p .community_id
181- FROM
182- post p
177+ UNION
178+ SELECT
179+ p .creator_id ,
180+ p .community_id
181+ FROM
182+ post p
183183 INNER JOIN person pe ON p .creator_id = pe .id
184184 WHERE
185185 p .published_at > (' now' ::timestamp - i::interval)
186186 AND pe .bot_account = FALSE
187- UNION
188- SELECT
189- pa .person_id ,
190- p .community_id
191- FROM
192- post_actions pa
187+ UNION
188+ SELECT
189+ pa .person_id ,
190+ p .community_id
191+ FROM
192+ post_actions pa
193193 INNER JOIN post p ON pa .post_id = p .id
194194 INNER JOIN person pe ON pa .person_id = pe .id
195195 WHERE
196196 pa .voted_at > (' now' ::timestamp - i::interval)
197197 AND pe .bot_account = FALSE
198- UNION
199- SELECT
200- ca .person_id ,
201- p .community_id
202- FROM
203- comment_actions ca
198+ UNION
199+ SELECT
200+ ca .person_id ,
201+ p .community_id
202+ FROM
203+ comment_actions ca
204204 INNER JOIN comment c ON ca .comment_id = c .id
205205 INNER JOIN post p ON c .post_id = p .id
206206 INNER JOIN person pe ON ca .person_id = pe .id
@@ -220,7 +220,7 @@ CREATE OR REPLACE FUNCTION r.community_aggregates_interactions (i text)
220220 LANGUAGE plpgsql
221221 AS $$
222222BEGIN
223- RETURN query
223+ RETURN QUERY
224224 SELECT
225225 COALESCE(sum (comments + upvotes + downvotes)::integer , 0 ) AS count_,
226226 community_id AS community_id_
Original file line number Diff line number Diff line change @@ -455,13 +455,13 @@ FROM
455455 user_ u
456456 LEFT JOIN community_follower cf ON u .id = cf .user_id
457457 AND cf .community_id = cv .id ) AS us
458- UNION ALL
459- SELECT
460- cv.* ,
461- NULL AS user_id,
462- NULL AS subscribed
463- FROM
464- community_aggregates_view cv;
458+ UNION ALL
459+ SELECT
460+ cv.* ,
461+ NULL AS user_id,
462+ NULL AS subscribed
463+ FROM
464+ community_aggregates_view cv;
465465
466466CREATE VIEW community_moderator_view AS
467467SELECT
Original file line number Diff line number Diff line change @@ -364,13 +364,13 @@ FROM
364364 user_ u
365365 LEFT JOIN community_follower cf ON u .id = cf .user_id
366366 AND cf .community_id = cv .id ) AS us
367- UNION ALL
368- SELECT
369- cv.* ,
370- NULL AS user_id,
371- NULL AS subscribed
372- FROM
373- community_aggregates_view cv;
367+ UNION ALL
368+ SELECT
369+ cv.* ,
370+ NULL AS user_id,
371+ NULL AS subscribed
372+ FROM
373+ community_aggregates_view cv;
374374
375375CREATE VIEW community_moderator_view AS
376376SELECT
Original file line number Diff line number Diff line change @@ -368,13 +368,13 @@ FROM
368368 user_ u
369369 LEFT JOIN community_follower cf ON u .id = cf .user_id
370370 AND cf .community_id = cv .id ) AS us
371- UNION ALL
372- SELECT
373- cv.* ,
374- NULL AS user_id,
375- NULL AS subscribed
376- FROM
377- community_aggregates_view cv;
371+ UNION ALL
372+ SELECT
373+ cv.* ,
374+ NULL AS user_id,
375+ NULL AS subscribed
376+ FROM
377+ community_aggregates_view cv;
378378
379379CREATE VIEW community_moderator_view AS
380380SELECT
Original file line number Diff line number Diff line change 7373 user_ u
7474 LEFT JOIN community_follower cf ON u .id = cf .user_id
7575 AND cf .community_id = cv .id ) AS us
76- UNION ALL
77- SELECT
78- cv.* ,
79- NULL AS user_id,
80- NULL AS subscribed
81- FROM
82- community_aggregates_view cv;
76+ UNION ALL
77+ SELECT
78+ cv.* ,
79+ NULL AS user_id,
80+ NULL AS subscribed
81+ FROM
82+ community_aggregates_view cv;
8383
8484-- The community fast table
8585CREATE TABLE community_aggregates_fast AS
Original file line number Diff line number Diff line change 7373 user_ u
7474 LEFT JOIN community_follower cf ON u .id = cf .user_id
7575 AND cf .community_id = cv .id ) AS us
76- UNION ALL
77- SELECT
78- cv.* ,
79- NULL AS user_id,
80- NULL AS subscribed
81- FROM
82- community_aggregates_view cv;
76+ UNION ALL
77+ SELECT
78+ cv.* ,
79+ NULL AS user_id,
80+ NULL AS subscribed
81+ FROM
82+ community_aggregates_view cv;
8383
8484-- The community fast table
8585CREATE TABLE community_aggregates_fast AS
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ CREATE OR REPLACE FUNCTION community_aggregates_activity (i text)
9898 LANGUAGE plpgsql
9999 AS $$
100100BEGIN
101- RETURN query
101+ RETURN QUERY
102102 SELECT
103103 count (* ),
104104 community_id
@@ -111,14 +111,14 @@ BEGIN
111111 INNER JOIN post p ON c .post_id = p .id
112112 WHERE
113113 c .published > (' now' ::timestamp - i::interval)
114- UNION
115- SELECT
116- p .creator_id ,
117- p .community_id
118- FROM
119- post p
120- WHERE
121- p .published > (' now' ::timestamp - i::interval)) a
114+ UNION
115+ SELECT
116+ p .creator_id ,
117+ p .community_id
118+ FROM
119+ post p
120+ WHERE
121+ p .published > (' now' ::timestamp - i::interval)) a
122122GROUP BY
123123 community_id;
124124END;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION community_aggregates_activity (i text)
55 LANGUAGE plpgsql
66 AS $$
77BEGIN
8- RETURN query
8+ RETURN QUERY
99 SELECT
1010 count (* ),
1111 community_id
@@ -18,14 +18,14 @@ BEGIN
1818 INNER JOIN post p ON c .post_id = p .id
1919 WHERE
2020 c .published > (' now' ::timestamp - i::interval)
21- UNION
22- SELECT
23- p .creator_id ,
24- p .community_id
25- FROM
26- post p
27- WHERE
28- p .published > (' now' ::timestamp - i::interval)) a
21+ UNION
22+ SELECT
23+ p .creator_id ,
24+ p .community_id
25+ FROM
26+ post p
27+ WHERE
28+ p .published > (' now' ::timestamp - i::interval)) a
2929GROUP BY
3030 community_id;
3131END;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ CREATE OR REPLACE FUNCTION community_aggregates_activity (i text)
66 LANGUAGE plpgsql
77 AS $$
88BEGIN
9- RETURN query
9+ RETURN QUERY
1010 SELECT
1111 count (* ),
1212 community_id
@@ -21,12 +21,12 @@ BEGIN
2121 WHERE
2222 c .published > (' now' ::timestamp - i::interval)
2323 AND pe .bot_account = FALSE
24- UNION
25- SELECT
26- p .creator_id ,
27- p .community_id
28- FROM
29- post p
24+ UNION
25+ SELECT
26+ p .creator_id ,
27+ p .community_id
28+ FROM
29+ post p
3030 INNER JOIN person pe ON p .creator_id = pe .id
3131 WHERE
3232 p .published > (' now' ::timestamp - i::interval)
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION community_aggregates_activity (i text)
55 LANGUAGE plpgsql
66 AS $$
77BEGIN
8- RETURN query
8+ RETURN QUERY
99 SELECT
1010 count (* ),
1111 community_id
@@ -20,12 +20,12 @@ BEGIN
2020 WHERE
2121 c .published > (' now' ::timestamp - i::interval)
2222 AND pe .bot_account = FALSE
23- UNION
24- SELECT
25- p .creator_id ,
26- p .community_id
27- FROM
28- post p
23+ UNION
24+ SELECT
25+ p .creator_id ,
26+ p .community_id
27+ FROM
28+ post p
2929 INNER JOIN person pe ON p .creator_id = pe .id
3030 WHERE
3131 p .published > (' now' ::timestamp - i::interval)
You can’t perform that action at this time.
0 commit comments