-
Notifications
You must be signed in to change notification settings - Fork 439
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
comments: Fix total comments count calculation #997
Conversation
please complete the checklist in the PR template |
Added an entry to CHANGES.rst |
ef019ef
to
4fa53aa
Compare
Please make a review of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes itself LGTM.
I found this really hard to review because of the terminologies (some values point are dicts (replies
) and others are integers (hidden_replies
), the request param parent
becomes id
in the response, and the meaning/calculation of reply_counts
was hard to wrap my head around). The existing code is quite clunky and I'm glad you nevertheless took the time to look into it and fix this longstanding issue @pkvach.
Please fix the two identically-named commits (either squash or split the tests/CHANGES changes into appropriately named commits)
cc31a31
to
6437845
Compare
Changes to properly count hidden comments when calculating the total number of comments. Fixes isso-comments#448
6437845
to
a952595
Compare
@ix5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for squashing, LGTM
Checklist
What changes does this Pull Request introduce?
Changes to properly count hidden comments when calculating the total number of comments.
isso/views/comments.py
: The calculation of total_replies is modified. Instead of directly assigning the value of reply_counts[root_id] to total_replies, it now calculates the sum of all values in reply_counts if root_id is None, otherwise it assigns the value of reply_counts[root_id].isso/js/embed.js
: The redundant incrementation of the count variable with comment.total_replies was removed.isso/tests/test_comments.py
: Several assertions are added to various test cases to check the value of total_replies in the response data.Why is this necessary?
Fixes #448
Demo