umputun / remark42

comment engine
https://remark42.com
MIT License
4.89k stars 378 forks source link

"Get comment by user id" API returns count including deleted comments #273

Open AnyRoad opened 5 years ago

AnyRoad commented 5 years ago

It might be done intentionally but right now the "get comment by user id" API returns total comments count in the "count" field. But it does not return deleted comments in the "comments" field which seems to be little bit inconsistent because we can get 1 comment and "3" as the count value if 2 others were deleted:

image
umputun commented 5 years ago

This is a known limitation due to the data model. Comment removal in many cases doesn't delete the record itself but cleaning it and sets 'deleted' flag. This is done to preserve possible references (parent-child tree). The way boltdb storage implements UserCount doesn't check every comment for the deleted flag, but gets Stats().KeyN directly.

This was done for performance reasons (mostly) because checking each comment could be a heavy task for some users. However, there is a better way to do it by maintaining per-user meta-information. I'm planning to add such meta bucket but after #155 solved.