]> Untitled Git - lemmy.git/blobdiff - migrations/2020-12-10-152350_create_post_aggregates/up.sql
Fixing comment count necro-bump issue.
[lemmy.git] / migrations / 2020-12-10-152350_create_post_aggregates / up.sql
index aaa611c4e9c5c8e17f21938d70d1b95821f16c3e..fcb3a9390593830f9addd4a70e8f079b47a3cb85 100644 (file)
@@ -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