Repository navigation
fix: list the newest 200 comments instead of the first 200 - #232
Merged
Merged
Conversation
findByComplaintId ordered comments oldest-first and then applied LIMIT 200, so once a complaint had more than 200 comments every new one was cut off and never showed up in the feed. Take the latest 200 and return them in chronological order, with id as a tie-break for same-second comments.
Owner
|
Not ready to merge yet. The newest-200 fix merges cleanly with current main, but CI on this head is awaiting maintainer approval. This is an approval gate, not a test failure. All three CI jobs need to pass before merge; no further code change is being requested at this point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
findByComplaintIdsorted ascending and then appliedLIMIT 200, so after 200 comments the list never changed again and new comments didn't show up in the feed.It now selects the newest 200 in a subquery (
ORDER BY created_at DESC, id DESC LIMIT 200) and returns them oldest-first.idis the tie-break, so comments posted within the same second keep their posting order.Tests
Added
backend/tests/commentListing.test.js(real SQLite test DB, like the other model tests):main, which returns 1–200.npm testinbackend: 84 passed.Fixes #231