From: Dessalines Date: Thu, 29 Aug 2019 04:28:06 +0000 (-0700) Subject: Showing community count on main sidebar X-Git-Url: http://these/git/readmes/%24%7B%60data:application/%7B%60%24%7BghostArchiveUrl%7D/%24%7BgetStaticDir%28%29%7D/js/%7Bs.link%7D?a=commitdiff_plain;h=b50ae1dafc7c34029809f6af252ca4886b0f8414;p=lemmy.git Showing community count on main sidebar - Fixes #232 --- diff --git a/server/migrations/2019-08-29-040006_add_community_count/down.sql b/server/migrations/2019-08-29-040006_add_community_count/down.sql new file mode 100644 index 00000000..6302f267 --- /dev/null +++ b/server/migrations/2019-08-29-040006_add_community_count/down.sql @@ -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; diff --git a/server/migrations/2019-08-29-040006_add_community_count/up.sql b/server/migrations/2019-08-29-040006_add_community_count/up.sql new file mode 100644 index 00000000..0ec1c9c3 --- /dev/null +++ b/server/migrations/2019-08-29-040006_add_community_count/up.sql @@ -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; diff --git a/server/src/db/community_view.rs b/server/src/db/community_view.rs index 88ab10af..a12d6bf9 100644 --- a/server/src/db/community_view.rs +++ b/server/src/db/community_view.rs @@ -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 { diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 0fab17f6..0a7a31e5 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -39,6 +39,7 @@ export class Main extends Component { 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 {
  • #
  • +
  • + # +
  • #
  • diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 251b64a0..c9a647d6 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -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 { diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index 85b5cab3..10c1540c 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -21,6 +21,7 @@ export const en = { subscribed_to_communities:'Subscribed to <1>communities', trending_communities:'Trending <1>communities', list_of_communities: 'List of communities', + number_of_communities:'{{count}} Communities', community_reqs: 'lowercase, underscores, and no spaces.', edit: 'edit', reply: 'reply',