"Wrong" comment count after discussion deletion - bug or feature?
By now the comment count of a user isn't updated when a discussion is deleted where he commented on. It has been reported as a bug on GitHub and I've tried my hands on a solution. @Linc had a very busy day yesterday reviewing a lot of pull requests, and that was one of them. It has been rejected, last but not least , because of performance considerations.
So before I thought about alternative solutions, I had a second thought about the problem itself. User A has written x comments, y were deleted and z comments remain. So if I look at user A's profile, what would I expect to see:
a) the number of comments that I can find when I look at /profile/comments/... (z) or
b) the number of comments a user has written (x)?
Hard to tell. If user A made 10 comments and I can only see 7, I would be clearly speaking of a bug - but only at first sight.
Look at the whole procedure for example here on vf.org: if user A made 10 comments, he gets a shiny badge! And why does he get it? Because he deserved it, defined by the rules for that badge. He has written 10 comments, and it doesn't count how many of his comments has been lost in a deleted discussion. He has deserved that badge. So nobody would want to remove that badge from him!
Okay, now if we look at user A's profile we see a comment count of 10 comments, a 10 comments badge and that's a fit: he definitely has written 10 comments and that's a true statement.
But what if we look at the list of comments? It shows only 7 comments, although user has written 10 comments. But if we agree on the fact that the 10 comments is somehow also a correct information which has to be kept so that actions depending on the 10th comment still make sense, we maybe don't have to think about the binary "show this or that number" decision. Maybe we have to provide additional information in order to get a consistent picture?
As I've said before, I had a second thought about the problem itself and to me now the best "solution" for this is to add the information "y deleted comments" to /profile/comments/... where "y" is simply users CountComments - pagers TotalRecords.