Skip to content

Fix comment count to match # of comments#73

Merged
csebianlander merged 2 commits intomainfrom
70-fix-comment-count
Aug 12, 2025
Merged

Fix comment count to match # of comments#73
csebianlander merged 2 commits intomainfrom
70-fix-comment-count

Conversation

@Anna-M-Thomas
Copy link
Collaborator

This pull request hopefully closes #70.

This operand ?: I guess is a shorthand for a ternary expression that "will evaluate as the first operand if it true, and the third operand otherwise" (link)

For statements like $commentsCount > 0 ?: 0 when the comment count was greater than 0, then the displayed comment count ended up being 1 for true.

I made a new method for the Post model that just returns a count of non-moderation action comments, because otherwise the comment count includes whenever a moderator adds, edits, blurs etc. a comment.

This pull request should fix the comment count for the homepage, on the page for a single post, and the archive page at /archives/YYYY/MM/DD (ex. archives/2025/08/12)

(The comment count on the page for a single post will be initially accurate, but the number is not updated when a new comment is posted. Only updates on reload)

Copy link
Collaborator

@wrose504 wrose504 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks!

@csebianlander csebianlander merged commit 928bd12 into main Aug 12, 2025
1 check passed
@wrose504 wrose504 deleted the 70-fix-comment-count branch August 21, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Comment count not changing on homepage

3 participants