From: Dessalines Date: Fri, 15 Jan 2021 16:58:56 +0000 (-0500) Subject: Fixing comment count necro-bump issue. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/static/README.zh.hant.md?a=commitdiff_plain;h=8f61a148f66e4318122ae98394503e3647f10e40;p=lemmy.git Fixing comment count necro-bump issue. --- diff --git a/migrations/2020-12-10-152350_create_post_aggregates/up.sql b/migrations/2020-12-10-152350_create_post_aggregates/up.sql index aaa611c4..fcb3a939 100644 --- a/migrations/2020-12-10-152350_create_post_aggregates/up.sql +++ b/migrations/2020-12-10-152350_create_post_aggregates/up.sql @@ -66,10 +66,13 @@ as $$ begin IF (TG_OP = 'INSERT') THEN update post_aggregates pa - set comments = comments + 1, - newest_comment_time = NEW.published - where pa.post_id = NEW.post_id + set comments = comments + 1 + where pa.post_id = NEW.post_id; + -- A 2 day necro-bump limit + update post_aggregates pa + set newest_comment_time = NEW.published + where pa.post_id = NEW.post_id and published > ('now'::timestamp - '2 days'::interval); ELSIF (TG_OP = 'DELETE') THEN -- Join to post because that post may not exist anymore