mirror of https://github.com/LemmyNet/lemmy.git
Community post count fix (#1062)
* User details ui fix * User details ui fix * Lang bio, merge * Community count posts bug #1060pull/1071/head
parent
221db1bd1b
commit
7bc560b2ec
|
@ -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;
|
|
@ -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;
|
|
@ -211,6 +211,7 @@
|
||||||
"powered_by": "Powered by",
|
"powered_by": "Powered by",
|
||||||
"landing_0": "Lemmy jest <1>agregatorem linków</1> / alternatywą dla reddita. Jest przeznaczony do działania w ramach cyfrowej przestrzeni nazywanej <2>fediverse</2>. <3></3>Opiera się na samodzielnym hostingu, posiada aktualizowane na żywo wątki z komentarzami, i zajmuje bardzo mało miejsce (<4>~80kB</4>). Federacja w ramach sieci ActivityPub jest w planach. <5></5>Ta wersja jest <6>bardzo wczesną wersją beta</6>, co oznacza, że wiele funkcji nadal nie działa tak jak powinny. <7></7><8>Pod tym adresem</8> można sugerować nową funkcjonalność i zgłaszać błędy.<9></9>Stworzono z wykorzystaniem <10>Rust</10>, <11>Actix</11>, <12>Inferno</12>, <13>Typescript</13>.",
|
"landing_0": "Lemmy jest <1>agregatorem linków</1> / alternatywą dla reddita. Jest przeznaczony do działania w ramach cyfrowej przestrzeni nazywanej <2>fediverse</2>. <3></3>Opiera się na samodzielnym hostingu, posiada aktualizowane na żywo wątki z komentarzami, i zajmuje bardzo mało miejsce (<4>~80kB</4>). Federacja w ramach sieci ActivityPub jest w planach. <5></5>Ta wersja jest <6>bardzo wczesną wersją beta</6>, co oznacza, że wiele funkcji nadal nie działa tak jak powinny. <7></7><8>Pod tym adresem</8> można sugerować nową funkcjonalność i zgłaszać błędy.<9></9>Stworzono z wykorzystaniem <10>Rust</10>, <11>Actix</11>, <12>Inferno</12>, <13>Typescript</13>.",
|
||||||
"not_logged_in": "Nie jesteś zalogowana/y.",
|
"not_logged_in": "Nie jesteś zalogowana/y.",
|
||||||
|
"bio_length_overflow": "To pole nie może przekraczać 300 znaków!",
|
||||||
"logged_in": "Zalogowano.",
|
"logged_in": "Zalogowano.",
|
||||||
"community_ban": "Zostałaś/eś zbanowana/y z tej społeczności.",
|
"community_ban": "Zostałaś/eś zbanowana/y z tej społeczności.",
|
||||||
"site_ban": "Zostałaś/eś zbanowana/y z tej witryny",
|
"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.",
|
"silver_sponsors": "Srebrni Sponsorzy to ci, którzy wpłacili co najmniej $40 na Lemmiego.",
|
||||||
"select_a_community": "Wybierz społeczność",
|
"select_a_community": "Wybierz społeczność",
|
||||||
"invalid_username": "Nieprawidłowa nazwa użytkownika.",
|
"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"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue