mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-24 23:30:56 +00:00
5c6258390c
* Adding a way to GetComments for a community given its name only. * Adding getcomments to api docs. * A first pass at locally working isomorphic integration. * Testing out cargo-husky. * Testing a fail hook. * Revert "Testing a fail hook." This reverts commit0941cf1736
. * Moving server to top level, now that UI is gone. * Running cargo fmt using old way. * Adding nginx, fixing up docker-compose files, fixing docs. * Trying to re-add API tests. * Fixing prod dockerfile. * Redoing nightly fmt * Trying to fix private message api test. * Adding CommunityJoin, PostJoin instead of joins from GetComments, etc. - Fixes #1122 * Fixing fmt. * Fixing up docs. * Removing translations. * Adding apps / clients to readme. * Fixing main image. * Using new lemmy-isomorphic-ui with better javascript disabled. * Try to fix image uploads in federation test * Revert "Try to fix image uploads in federation test" This reverts commita2ddf2a90b
. * Fix post url federation * Adding some more tests, some still broken. * Don't need gitattributes anymore. * Update local federation test setup * Fixing tests. * Fixing travis build. * Fixing travis build, again. * Changing lemmy-isomorphic-ui to lemmy-ui * Error in travis build again. Co-authored-by: Felix Ableitner <me@nutomic.com>
54 lines
1.7 KiB
SQL
54 lines
1.7 KiB
SQL
create view community_view as
|
|
with all_community as
|
|
(
|
|
select *,
|
|
(select name from user_ u where c.creator_id = u.id) as creator_name,
|
|
(select name from category ct where c.category_id = ct.id) as category_name,
|
|
(select count(*) from community_follower cf where cf.community_id = c.id) as number_of_subscribers,
|
|
(select count(*) from post p where p.community_id = c.id) as number_of_posts,
|
|
(select count(*) from comment co, post p where c.id = p.community_id and p.id = co.post_id) as number_of_comments
|
|
from community c
|
|
)
|
|
|
|
select
|
|
ac.*,
|
|
u.id as user_id,
|
|
(select cf.id::boolean from community_follower cf where u.id = cf.user_id and ac.id = cf.community_id) as subscribed
|
|
from user_ u
|
|
cross join all_community ac
|
|
|
|
union all
|
|
|
|
select
|
|
ac.*,
|
|
null as user_id,
|
|
null as subscribed
|
|
from all_community ac
|
|
;
|
|
|
|
create view community_moderator_view as
|
|
select *,
|
|
(select name from user_ u where cm.user_id = u.id) as user_name,
|
|
(select name from community c where cm.community_id = c.id) as community_name
|
|
from community_moderator cm;
|
|
|
|
create view community_follower_view as
|
|
select *,
|
|
(select name from user_ u where cf.user_id = u.id) as user_name,
|
|
(select name from community c where cf.community_id = c.id) as community_name
|
|
from community_follower cf;
|
|
|
|
create view community_user_ban_view as
|
|
select *,
|
|
(select name from user_ u where cm.user_id = u.id) as user_name,
|
|
(select name from community c where cm.community_id = c.id) as community_name
|
|
from community_user_ban cm;
|
|
|
|
create view site_view as
|
|
select *,
|
|
(select name from user_ u where s.creator_id = u.id) as creator_name,
|
|
(select count(*) from user_) as number_of_users,
|
|
(select count(*) from post) as number_of_posts,
|
|
(select count(*) from comment) as number_of_comments
|
|
from site s;
|