Skip to content

fix: list the newest 200 comments instead of the first 200 - #232

Merged
Janani-bn merged 1 commit into
Janani-bn:mainfrom
saisarans2007:fix/comments-show-newest
Nov 15, 2026
Merged

Janani-bn merged 1 commit into
Janani-bn:mainfrom
saisarans2007:fix/comments-show-newest

Conversation

@saisarans2007

Copy link
Copy Markdown
Contributor

Summary

findByComplaintId sorted ascending and then applied LIMIT 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. id is 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):

  • 205 comments: the list holds comments 6–205 in order. This fails on main, which returns 1–200.
  • three comments in the same second come back in posting order

npm test in backend: 84 passed.

Fixes #231

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.
@Janani-bn

Copy link
Copy Markdown
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.

@Janani-bn
Janani-bn merged commit 1577221 into Janani-bn:main Nov 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comments list is stuck at the first 200, new comments never appear

2 participants