PERF: Optimize the calculation of participant post counting (PR #10210)

GitHub

I find it’s a good idea to do ||= here to help Rails’ reloader.

I feel like we probably need more tests here.

There seems to be a fair bit of new logic here: how confident are you that it’s being tested by this and existing specs?

What’s your reasoning for having a CONSTANT as well as a self. method? Usually we do one or the other.

The self. in these two methods is not necessary.

Same suggestion as above: ||=

I am not a fan of adding/removing consts in tests. Is there any way you could rely only on class methods and then stub them?

The title of this pull request changed from “PERF: Cache the number of posts people created in large topics” to "PERF: Optimize the calculation of participant post counting

Replaced the cache with @SamSaffron’s recalculation idea.

not a fan of adding TODOs into comments we can track them elsewhere.

This is a great change, feel free to merge once you remove the TODO comments.

Also can you confirm there is test coverage for with whispers and without whispers?

Also can you confirm there is test coverage for with whispers and without whispers?

Yes, the test that received a patch is verifying the whisper / non-whisper post count.