Cache comment counts

Description

Cache the number of comments in the work meta (i.e. the box on the top of the work, not the blurb on work listings), and in the links for showing/hiding comments on works, tags, or admin posts.

ticking instant says:

Probably the best thing to do is to add a cache block to the count_visible_commentsfunction.

Testing

Make sure the count changes quickly when:

  • Posting a new comment

  • Deleting a comment (must be creator of the work or an admin)

  • Marking a logged out comment as spam (works and admin posts only; must be creator of the work or an admin)

  • Unmarking a logged out comment as spam (works and admin posts only; must be creator of the work or an admin)

  • Approving a moderated comment (works only; must be logged in as a creator of the work and have comments set to moderated)

The count will not update nearly as quickly for guests, since we use full page caching there.

Notes

This is split off from , which originally combined caching comments and comment counts. However, it’s not necessary to do both at once.

Activity

Show:
Sarken
January 25, 2021, 6:55 PM

On a work that initially had 14 comments, the count in the meta and on the comment button…

  • immediately increased to 15 when I posted a comment

  • immediately decreased to 14 when I deleted a comment

  • remained the same when I posted a comment that went into moderation

  • immediately increased to 15 when I approved the moderated comment

  • immediately decreased to 14 when I marked a comment as spam

  • immediately increased to 15 when I unmarked the comment as spam

(It’s probably worth noting that we have full page caching for logged out users, so the number only increased/decreased immediately if logged in. Actually, I should probably add that to the testing info…)

redsummernight
January 30, 2021, 1:16 PM

On a work with 4 comments, the count in the meta and on the show/hide comments button:

  • immediately went to 5 when posting a new comment

  • immediately went to 4 when deleting a comment

  • stayed 4 when leaving a guest comment that needed moderation

  • immediately went to 5 when approving the guest comment (as creator)

  • went to 4 when the guest comment is marked as spam (as creator)

  • went to 5 when the guest comment is unmarked as spam (as admin)

All count changes are checked while logged in.

redsummernight
January 30, 2021, 1:23 PM

On an admin post with 1 comment, the count on the show/hide comments button:

  • immediately went to 2 when posting a new comment (as user)

  • immediately went to 1 when deleting the previous comment (as the same user)

  • immediately went to 2 when posting a new comment (as guest)

  • immediately went to 1 when marking a guest comment as spam (as admin)

  • immediately went to 2 when unmarking a guest comment as spam (as admin)

All count changes are checked while logged in, both as a user and as an admin.

Looks good.

lydia-theda
January 30, 2021, 2:08 PM

Admin post with 15 comments:

  • immediately went to 16 when posting a new comment as a user

  • immediately went to 15 when deleting a different comment (same user)

  • immediately went to 16 when unspamming a comment (as admin)

  • immediately went to 15 when marking a comment as spam (admin)

  • immediately went to 16 when leaving a guest (well, admin) comment

Looks good

DeployedToBeta

Assignee

ticking instant

Reporter

Sarken

Roadmap

Comments

Priority

Medium

Affects versions

Fix versions

Components

Caching

Difficulty

Medium

Milestone

Internal 0.9