mitodl/open-discussions

Comment count includes spam comments

Closed this issue · 6 comments

Steps to Reproduce

  1. Make a post
  2. Make a comment on the post
  3. Mark the post as spam (requires django admin user or user with moderator role)
  4. View the post as an anonymous user

For example, see https://open.mit.edu/c/maca/56q/webinar-by-prof-mark-z-jacobson-stanford

Expected Behavior

  • The count of comments below the post should not include the count of spam comments.

Screenshot or Screencast

image

Fixing this would be best done as part of #3043 since the inclusion of spam comments in the value comes from reddit.

In comments, we do increment the number of comments, we have a bunch of spam handling in django that I think we can just decrement that number in when a comment is marked as such. Going to add a function to do that and test.

Circling back to that idea - that would fix future spam comment counts, but all current counts would still be askew. Glad I got sidetracked by API before doing so.

To modify this using the current method of showing comment count, wouldn't allow for the fix of past comments without some big script to re-count all comments.

The other option would be to change how we display comment count from a counter (current) to a .count() of not deleted or removed comments.

Currently, spam comments aren't the only ones counted erroneously. It also adds and never removes deleted comments from that count :)

@rhysyngsun
Do you think it's worth putting together a PR annotating posts with something like (pardon the terrible pseudo code) count('comment__not_removed')+count('comment__not_deleted') and using that (potentially very costly) query to generate comment counts rather than the very incorrect counter?

@JenniWhitman no, I don't think we should do anything that'll worsen performance. I think this is best left until we make the time to address the whole reddit dependency because it just patches over that pain with more pain (worse performance).

Ferdi commented

We can hide the comments counter for now