Showing community count on main sidebar

- Fixes #232
This commit is contained in:
Dessalines 2019-08-28 21:28:06 -07:00
parent 37c0f751d0
commit 1c59f06fc8
6 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,9 @@
drop view site_view;
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;

View File

@ -0,0 +1,10 @@
drop view site_view;
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,
(select count(*) from community) as number_of_communities
from site s;

View File

@ -69,6 +69,7 @@ table! {
number_of_users -> BigInt,
number_of_posts -> BigInt,
number_of_comments -> BigInt,
number_of_communities -> BigInt,
}
}
@ -253,6 +254,7 @@ pub struct SiteView {
pub number_of_users: i64,
pub number_of_posts: i64,
pub number_of_comments: i64,
pub number_of_communities: i64,
}
impl SiteView {

View File

@ -39,6 +39,7 @@ export class Main extends Component<any, MainState> {
number_of_users: null,
number_of_posts: null,
number_of_comments: null,
number_of_communities: null,
},
admins: [],
banned: [],
@ -217,6 +218,9 @@ export class Main extends Component<any, MainState> {
<li className="list-inline-item badge badge-secondary">
<T i18nKey="number_of_users" interpolation={{count: this.state.site.site.number_of_users}}>#</T>
</li>
<li className="list-inline-item badge badge-secondary">
<T i18nKey="number_of_communities" interpolation={{count: this.state.site.site.number_of_communities}}>#</T>
</li>
<li className="list-inline-item badge badge-secondary">
<T i18nKey="number_of_posts" interpolation={{count: this.state.site.site.number_of_posts}}>#</T>
</li>

View File

@ -135,6 +135,7 @@ export interface Site {
number_of_users: number;
number_of_posts: number;
number_of_comments: number;
number_of_communities: number;
}
export interface FollowCommunityForm {

View File

@ -21,6 +21,7 @@ export const en = {
subscribed_to_communities:'Subscribed to <1>communities</1>',
trending_communities:'Trending <1>communities</1>',
list_of_communities: 'List of communities',
number_of_communities:'{{count}} Communities',
community_reqs: 'lowercase, underscores, and no spaces.',
edit: 'edit',
reply: 'reply',