Log in

Unread comments count

  • 5 Sep '16

I've seen this happen more than a few times, so I believe there is a bug in the unread comment count. Sometimes I notice a topic is at the top of the list, but the unread count shows 0. When I click on the topic I'm sent to the latest comment I read, which is not the last comment in the topic.

I wasn't able to reproduce it locally, and it rarely happens to me live, so it's again one of those pesky bugs :/

nitelyEsteban Castro Borsani
  • 1
  • 6 Sep '16

Does the topic has a moderation action in it? (ie: topic has been pinned, closed, etc)

  • 6 Sep '16

@nitely said:
Does the topic has a moderation action in it? (ie: topic has been pinned, closed, etc)

nope, regular comments

nitelyEsteban Castro Borsani
  • 6 Sep '16

It's gonna be one of those bugs then XD

I know something like that happens when there is a moderation action within the topic (in any of the pages)

nitelyEsteban Castro Borsani
  • 4
  • 8 Sep '16

I review the code and I found:

  • When one or more comments are moved, the users bookmarks are not updated to the latest comment they read that it is still in the topic (ie: was not moved). But in this case, clicking the topic would take you either to the first comment or some newer comment you have not read.

Other than that, I dunno where to look, I'm out of ideas.

I checked if it could be a race condition, but I don't think so. The topic's "comment_count" is updated at the same time as the "last_active" time.

Next time you notice a the issue, if you are able to notice it before entering the topic, check if the topic is shown in the "Unread topics" section. That would rule out any issue not related to bookmarks.

Also, check what's your bookmark for that topic, like this:

$ python manage.py shell
$ from spirit.comment.bookmark import models
$ models.CommentBookmark.objects.get(user={your_id}, topic={topic_id}).comment_number

That should print something lesser than the topic's comments count. Do all that before entering the topic.

Also check if refreshing the page/browser makes any difference (it should not).

Also check the web console. The bookmark count thing should be displayed with JS, so if there is a JS error may be that code never runs.

  • 22 Sep '16

Oook, so it just happened again. There was a topic at the very top of /topic/active/ but with no unread comments icon. I know for a fact there was something new because I looked at it in incognito.

First thing I did was refresh the page, which didn't help. After somebody else also commented on the topic, the unread count went up to 1, while it should actually be 2.

My comment_number 72, which is correct. However, there are 77 comments in the topic now (more people commented in the meantime).

There is not JS error, and other unread topic counts look fine.

Actually, I just noticed that the displayed comment count (74) is wrong? It should be 77 according to the shell.

Here's the direct commands I ran in the shell (at the same time as refreshed the page obviously):

>>> from spirit.comment.bookmark import models
>>> models.CommentBookmark.objects.get(user=2, topic=618).comment_number
>>> from spirit.topic.models import Topic
>>> Topic.objects.get(id=618).comment_set.count()
  • 1
  • 22 Sep '16

77 - 74 = 3 which is exactly how many unread counts I'm missing (I should have 5 unread, but have 2).

>>> Topic.objects.get(id=618).comment_count
  • 22 Sep '16

Ok I got it. The topic was pinned/unpinned 3 times. I'm guessing the pin action does not add to the comment count

nitelyEsteban Castro Borsani
  • 2
  • 22 Sep '16

Ok I got it. The topic was pinned/unpinned 3 times. I'm guessing the pin action does not add to the comment count

Nop, it does not. Not only that, I remember it completely messes up the combination of unread counter and last read comment (I don't remember exactly how). There is a bug there for sure.

It's easy to replicate though. I will try to fix it ASAP. Funny thing is I actually knew how to fix it, but I forgot it

Past me wrote something about it:

add post_count? to track all post in a topic (moderator actions included), there is aproblem with bookmarks and actions here

Dunno how useful it is.

nitelyEsteban Castro Borsani
  • 30 Sep '16

I created an issue for this one.