Remove duplicates from downloaded completion lists#1308
Conversation
📝 WalkthroughWalkthroughMoves de-duplication from DB DISTINCT/ORDER BY into client-side filtering: keep the earliest completion per user, then sort results by last_name, first_name, id. Rows now render from the filtered set and completion_date is stringified when present. Changes
Estimated Code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@backend/api/routes/completions.ts`:
- Line 231: Replace the garbled comment "Sort by usuniqueCr name and ID" with a
clear, correct description—e.g., "Sort by user name and ID" or, if sorting by
surname then given name, "Sort by last name, first name, and ID"—by editing the
comment line containing "Sort by usuniqueCr name and ID" in completions.ts so it
accurately reflects the actual sort order used.
- Around line 221-229: The deduplication result stored in uniqueCompletions is
never used — the code still maps over completions, so duplicates and the sorting
are ignored; replace the subsequent usage of completions with uniqueCompletions
(or rename uniqueCompletions to completions and remove the old array) so that
the mapping/response uses the filtered set, ensuring the dedupe logic involving
seenUsers and uniqueCompletions takes effect.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1308 +/- ##
==========================================
+ Coverage 62.83% 65.57% +2.73%
==========================================
Files 151 154 +3
Lines 6388 6602 +214
Branches 1580 1634 +54
==========================================
+ Hits 4014 4329 +315
+ Misses 2204 2120 -84
+ Partials 170 153 -17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.