2 ADD COLUMN nsfw boolean DEFAULT FALSE NOT NULL;
5 ADD COLUMN nsfw boolean DEFAULT FALSE NOT NULL;
8 ADD COLUMN show_nsfw boolean DEFAULT FALSE NOT NULL;
11 DROP VIEW community_view;
13 CREATE VIEW community_view AS
14 with all_community AS (
23 c.creator_id = u.id) AS creator_name,
30 c.category_id = ct.id) AS category_name,
37 cf.community_id = c.id) AS number_of_subscribers,
44 p.community_id = c.id) AS number_of_posts,
53 AND p.id = co.post_id) AS number_of_comments,
57 FROM community_follower cf
59 cf.community_id = c.id), c.published) AS hot_rank
73 AND ac.id = cf.community_id) AS subscribed
76 CROSS JOIN all_community ac
88 CREATE VIEW post_view AS
98 p.creator_id = user_.id) AS creator_name,
105 p.community_id = community.id) AS community_name,
112 p.community_id = c.id) AS community_removed,
119 p.community_id = c.id) AS community_deleted,
126 p.community_id = c.id) AS community_nsfw,
133 comment.post_id = p.id) AS number_of_comments,
134 coalesce(sum(pl.score), 0) AS score,
136 CASE WHEN pl.score = 1 THEN
142 CASE WHEN pl.score = - 1 THEN
147 hot_rank (coalesce(sum(pl.score), 0), p.published) AS hot_rank
150 LEFT JOIN post_like pl ON p.id = pl.post_id
157 coalesce(pl.score, 0) AS my_vote,
162 community_follower cf
165 AND cf.community_id = ap.community_id) AS subscribed,
173 AND pr.post_id = ap.id) AS read,
181 AND ps.post_id = ap.id) AS saved
184 CROSS JOIN all_post ap
185 LEFT JOIN post_like pl ON u.id = pl.user_id
186 AND ap.id = pl.post_id