Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Wrong comments count for an updated research item #3510

Closed
codisart opened this issue May 8, 2024 · 4 comments · Fixed by #3579
Closed

[bug] Wrong comments count for an updated research item #3510

codisart opened this issue May 8, 2024 · 4 comments · Fixed by #3579
Assignees

Comments

@codisart
Copy link
Contributor

codisart commented May 8, 2024

Describe the bug

When looking at the comments posted by @benfurber trying to reproduce the bug for #3508, I think I found a bug with the count of comments for a research

To Reproduce
Steps to reproduce the behaviour:

  1. Go to /research/lc-test-240506-0059
  2. See on the research statistics that the count is 6
  3. Scroll down to each update
  4. See that the counts is respectely 2 and 6

Expected behaviour

The count should be 8

Screenshots

Screenshot 2024-05-08 at 21 15 09

Additional context

I think the bug come from possible race conditions with

await dbRef.update({
  mentions: users
    .map((userName) => ({
      username: userName,
      location: `update-${existingUpdateIndex}-comment:${newComment?._id}`,
    }))
    .concat(researchItem.mentions || []),
  totalCommentCount: (researchItem.totalCommentCount || 0) + 1,
} as any)
@codisart
Copy link
Contributor Author

codisart commented May 9, 2024

Hi @benfurber, did you delete your two comments from the update 1 of /research/lc-test-240506-0059 ? It seems that I managed to add a reply after that it is considered valid and counted but can not be displayed. Does it seem possible to you ?

Maybe there is another bug here. I think we should not be able to add a reply to a deleted comment.

@benfurber
Copy link
Member

Hi @benfurber, did you delete your two comments from the update 1 of /research/lc-test-240506-0059 ? It seems that I managed to add a reply after that it is considered valid and counted but can not be displayed. Does it seem possible to you ?

Yes, another bug you've found! Could you write up in another issue how you think that could be implemented please?

@mariojsnunes
Copy link
Collaborator

mariojsnunes commented May 24, 2024

I found two issues:

  1. There are two variables tracking the count: totalCommentCount and commentCount, should be only 1.
    Currently the search is using totalCommentCount for sorting so would be easier to use that.
  2. Cannot find where we are adding/subtracting the research update comments to the research comment count.

@benfurber
Copy link
Member

@mariojsnunes Sorry, I should have assigned this to myself. I've got a fix in #3450 and then was going to refactor all the unneccessarily different commentCount naming in a follow-up.

@benfurber benfurber self-assigned this May 24, 2024
@benfurber benfurber linked a pull request May 24, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment