summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDessalines <happydooby@gmail.com>2019-04-04 13:00:19 -0700
committerDessalines <happydooby@gmail.com>2019-04-04 13:00:19 -0700
commit5e23f00672b1a6b6e76694622da19c108ce4e3a5 (patch)
tree41ef81c91c558f8d7841f58ce53d0bfb745863e7 /server
parent7b1fb030b306306ed65999bff05a5d0924a37158 (diff)
Adding forum / community page
- Adding the page. Fixes #17. - Adding number of comments for community. - Add sorting to that table.
Diffstat (limited to 'server')
-rw-r--r--server/migrations/2019-04-03-155205_create_community_view/up.sql3
-rw-r--r--server/src/actions/community_view.rs4
2 files changed, 5 insertions, 2 deletions
diff --git a/server/migrations/2019-04-03-155205_create_community_view/up.sql b/server/migrations/2019-04-03-155205_create_community_view/up.sql
index 74972507..d26a313e 100644
--- a/server/migrations/2019-04-03-155205_create_community_view/up.sql
+++ b/server/migrations/2019-04-03-155205_create_community_view/up.sql
@@ -3,7 +3,8 @@ 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 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;
create view community_moderator_view as
diff --git a/server/src/actions/community_view.rs b/server/src/actions/community_view.rs
index 9da6215d..03d822ab 100644
--- a/server/src/actions/community_view.rs
+++ b/server/src/actions/community_view.rs
@@ -17,6 +17,7 @@ table! {
category_name -> Varchar,
number_of_subscribers -> BigInt,
number_of_posts -> BigInt,
+ number_of_comments -> BigInt,
}
}
@@ -34,7 +35,8 @@ pub struct CommunityView {
pub creator_name: String,
pub category_name: String,
pub number_of_subscribers: i64,
- pub number_of_posts: i64
+ pub number_of_posts: i64,
+ pub number_of_comments: i64
}
impl CommunityView {