Skip to content

Conversation

@Redande
Copy link
Contributor

@Redande Redande commented Jan 23, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Removed duplicate completion records so each user appears only once, keeping their earliest completion.
  • Improvements

    • Completion results now ordered by user last name, first name, then ID.
    • Completion dates consistently formatted as strings in result rows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Moves 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

Cohort / File(s) Summary
Query handling & client-side de-duplication
backend/api/routes/completions.ts
Removed DISTINCT ON (u.id, com.course_id) and related DB ORDER BYs; added client-side filter to retain only the earliest completion_date per user (using a seen set); sort filtered entries by last_name, first_name, id; render rows from uniqueCompletions; stringify completion_date when present.

Estimated Code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped from SQL fields to client-side light,
I kept the oldest stars in a neat little sight.
Names lined up tidy, dates turned to strings,
A bunny-approved sort for meaningful things.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: removing duplicate completions from downloaded lists, which aligns with the core implementation of the per-user de-duplication logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.57%. Comparing base (7334d72) to head (7d0793c).
⚠️ Report is 2 commits behind head on master.

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     
Flag Coverage Δ
backend 65.57% <ø> (+2.73%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nygrenh nygrenh merged commit 4152a3c into master Jan 23, 2026
7 checks passed
@nygrenh nygrenh deleted the remove-duplicates-from-downloaded-completion-lists branch January 23, 2026 14:59
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.

3 participants