From: ernestwisniewski Date: Sun, 9 Aug 2020 18:50:27 +0000 (+0200) Subject: Community post count fix (#1062) X-Git-Url: http://these/git/%22https:/image.com/%7B%60%24%7BghostArchiveUrl%7D/static/readmes/README.zh.hans.md?a=commitdiff_plain;h=7bc560b2ec5227dd513330a511d68ca4c3e46723;p=lemmy.git Community post count fix (#1062) * User details ui fix * User details ui fix * Lang bio, merge * Community count posts bug #1060 --- diff --git a/server/migrations/2020-08-06-205355_update_community_post_count/down.sql b/server/migrations/2020-08-06-205355_update_community_post_count/down.sql new file mode 100644 index 00000000..53b016c8 --- /dev/null +++ b/server/migrations/2020-08-06-205355_update_community_post_count/down.sql @@ -0,0 +1,100 @@ +-- Drop first +drop view community_view; +drop view community_aggregates_view; +drop view community_fast_view; +drop table community_aggregates_fast; + +create view community_aggregates_view as +select + c.id, + c.name, + c.title, + c.icon, + c.banner, + c.description, + c.category_id, + c.creator_id, + c.removed, + c.published, + c.updated, + c.deleted, + c.nsfw, + c.actor_id, + c.local, + c.last_refreshed_at, + u.actor_id as creator_actor_id, + u.local as creator_local, + u.name as creator_name, + u.preferred_username as creator_preferred_username, + u.avatar as creator_avatar, + cat.name as category_name, + coalesce(cf.subs, 0) as number_of_subscribers, + coalesce(cd.posts, 0) as number_of_posts, + coalesce(cd.comments, 0) as number_of_comments, + hot_rank(cf.subs, c.published) as hot_rank +from community c +left join user_ u on c.creator_id = u.id +left join category cat on c.category_id = cat.id +left join ( + select + p.community_id, + count(distinct p.id) as posts, + count(distinct ct.id) as comments + from post p + join comment ct on p.id = ct.post_id + group by p.community_id +) cd on cd.community_id = c.id +left join ( + select + community_id, + count(*) as subs + from community_follower + group by community_id +) cf on cf.community_id = c.id; + +create view community_view as +select + cv.*, + us.user as user_id, + us.is_subbed::bool as subscribed +from community_aggregates_view cv +cross join lateral ( + select + u.id as user, + coalesce(cf.community_id, 0) as is_subbed + from user_ u + left join community_follower cf on u.id = cf.user_id and cf.community_id = cv.id +) as us + +union all + +select + cv.*, + null as user_id, + null as subscribed +from community_aggregates_view cv; + +-- The community fast table + +create table community_aggregates_fast as select * from community_aggregates_view; +alter table community_aggregates_fast add primary key (id); + +create view community_fast_view as +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 ( + select + ca.* + from community_aggregates_fast ca +) ac + +union all + +select +caf.*, +null as user_id, +null as subscribed +from community_aggregates_fast caf; \ No newline at end of file diff --git a/server/migrations/2020-08-06-205355_update_community_post_count/up.sql b/server/migrations/2020-08-06-205355_update_community_post_count/up.sql new file mode 100644 index 00000000..de5d447d --- /dev/null +++ b/server/migrations/2020-08-06-205355_update_community_post_count/up.sql @@ -0,0 +1,100 @@ +-- Drop first +drop view community_view; +drop view community_aggregates_view; +drop view community_fast_view; +drop table community_aggregates_fast; + +create view community_aggregates_view as +select + c.id, + c.name, + c.title, + c.icon, + c.banner, + c.description, + c.category_id, + c.creator_id, + c.removed, + c.published, + c.updated, + c.deleted, + c.nsfw, + c.actor_id, + c.local, + c.last_refreshed_at, + u.actor_id as creator_actor_id, + u.local as creator_local, + u.name as creator_name, + u.preferred_username as creator_preferred_username, + u.avatar as creator_avatar, + cat.name as category_name, + coalesce(cf.subs, 0) as number_of_subscribers, + coalesce(cd.posts, 0) as number_of_posts, + coalesce(cd.comments, 0) as number_of_comments, + hot_rank(cf.subs, c.published) as hot_rank +from community c +left join user_ u on c.creator_id = u.id +left join category cat on c.category_id = cat.id +left join ( + select + p.community_id, + count(distinct p.id) as posts, + count(distinct ct.id) as comments + from post p + left join comment ct on p.id = ct.post_id + group by p.community_id +) cd on cd.community_id = c.id +left join ( + select + community_id, + count(*) as subs + from community_follower + group by community_id +) cf on cf.community_id = c.id; + +create view community_view as +select + cv.*, + us.user as user_id, + us.is_subbed::bool as subscribed +from community_aggregates_view cv +cross join lateral ( + select + u.id as user, + coalesce(cf.community_id, 0) as is_subbed + from user_ u + left join community_follower cf on u.id = cf.user_id and cf.community_id = cv.id +) as us + +union all + +select + cv.*, + null as user_id, + null as subscribed +from community_aggregates_view cv; + +-- The community fast table + +create table community_aggregates_fast as select * from community_aggregates_view; +alter table community_aggregates_fast add primary key (id); + +create view community_fast_view as +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 ( + select + ca.* + from community_aggregates_fast ca +) ac + +union all + +select +caf.*, +null as user_id, +null as subscribed +from community_aggregates_fast caf; \ No newline at end of file diff --git a/ui/translations/pl.json b/ui/translations/pl.json index 4c737b3f..48c013be 100644 --- a/ui/translations/pl.json +++ b/ui/translations/pl.json @@ -211,6 +211,7 @@ "powered_by": "Powered by", "landing_0": "Lemmy jest <1>agregatorem linków / alternatywą dla reddita. Jest przeznaczony do działania w ramach cyfrowej przestrzeni nazywanej <2>fediverse. <3>Opiera się na samodzielnym hostingu, posiada aktualizowane na żywo wątki z komentarzami, i zajmuje bardzo mało miejsce (<4>~80kB). Federacja w ramach sieci ActivityPub jest w planach. <5>Ta wersja jest <6>bardzo wczesną wersją beta, co oznacza, że wiele funkcji nadal nie działa tak jak powinny. <7><8>Pod tym adresem można sugerować nową funkcjonalność i zgłaszać błędy.<9>Stworzono z wykorzystaniem <10>Rust, <11>Actix, <12>Inferno, <13>Typescript.", "not_logged_in": "Nie jesteś zalogowana/y.", + "bio_length_overflow": "To pole nie może przekraczać 300 znaków!", "logged_in": "Zalogowano.", "community_ban": "Zostałaś/eś zbanowana/y z tej społeczności.", "site_ban": "Zostałaś/eś zbanowana/y z tej witryny", @@ -263,5 +264,7 @@ "silver_sponsors": "Srebrni Sponsorzy to ci, którzy wpłacili co najmniej $40 na Lemmiego.", "select_a_community": "Wybierz społeczność", "invalid_username": "Nieprawidłowa nazwa użytkownika.", - "invalid_community_name": "Niepoprawna nazwa." + "invalid_community_name": "Niepoprawna nazwa.", + "play_captcha_audio": "Odsłuchaj Captcha Audio", + "bio": "Bio" }