parent
de8c2198af
commit
b50ae1dafc
6 changed files with 27 additions and 0 deletions
9
server/migrations/2019-08-29-040006_add_community_count/down.sql
vendored
Normal file
9
server/migrations/2019-08-29-040006_add_community_count/down.sql
vendored
Normal 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;
|
10
server/migrations/2019-08-29-040006_add_community_count/up.sql
vendored
Normal file
10
server/migrations/2019-08-29-040006_add_community_count/up.sql
vendored
Normal 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;
|
|
@ -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 {
|
||||
|
|
4
ui/src/components/main.tsx
vendored
4
ui/src/components/main.tsx
vendored
|
@ -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>
|
||||
|
|
1
ui/src/interfaces.ts
vendored
1
ui/src/interfaces.ts
vendored
|
@ -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 {
|
||||
|
|
1
ui/src/translations/en.ts
vendored
1
ui/src/translations/en.ts
vendored
|
@ -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',
|
||||
|
|
Reference in a new issue