Skip to content

sort by most recent reviews by default#1230

Merged
Jay-Lalwani merged 1 commit intodevfrom
order-by-most-recent
Mar 29, 2026
Merged

sort by most recent reviews by default#1230
Jay-Lalwani merged 1 commit intodevfrom
order-by-most-recent

Conversation

@jackrhoa
Copy link
Copy Markdown
Collaborator

@jackrhoa jackrhoa commented Mar 22, 2026

What I did

  • Switched default review ordering to most recent (was previously oldest)

Screenshots

  • Before

It worked on my local version

  • After

Testing

  • A brief explanation of tests done/written or how reviewers can test your work

Questions/Discussions/Notes

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed the default review sorting behavior. Reviews are now consistently ordered by creation date in descending order (newest first) when the default sort method is applied. Previously, using the default sort could result in unpredictable ordering. This ensures all users see reviews in a reliable and consistent sequence.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

The Review.sort(...) method's default branch behavior was updated to explicitly order reviews by -created timestamp instead of returning an unordered queryset when the method parameter is unrecognized or set to "Default".

Changes

Cohort / File(s) Summary
Review Sorting Logic
tcf_website/models/models.py
Modified default sort behavior in Review.sort(...) to order results by -created timestamp for unrecognized method values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 Hops with glee through sorted rows,
Fresh reviews in chronological flows,
Default now knows its proper way—
Newest first, hooray, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'sort by most recent reviews by default' directly and clearly summarizes the main change—updating the default review ordering to most recent.
Description check ✅ Passed The PR description covers the key required sections from the template (What I did, Screenshots, Testing, Questions/Notes), though some sections lack detail and the 'GitHub Issues addressed' section is missing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch order-by-most-recent

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.

@jackrhoa jackrhoa requested a review from Jay-Lalwani March 29, 2026 18:06
@jackrhoa jackrhoa marked this pull request as ready for review March 29, 2026 18:06
Copy link
Copy Markdown
Contributor

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

🧹 Nitpick comments (1)
tcf_website/models/models.py (1)

1339-1342: LGTM - default ordering now matches "Most Recent".

The change correctly implements the PR objective. One optional refinement: since "Most Recent" and the default case now share identical logic, you could combine them:

case "Most Recent" | "Default" | _:
    return reviews.order_by("-created")

This makes the equivalence explicit and reduces duplication, but the current form is also fine as it documents the intended behavior for each case separately.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tcf_website/models/models.py` around lines 1339 - 1342, The match/case block
that returns ordering for reviews currently has duplicate branches for "Most
Recent" and the default branch; update the match arms in the function containing
this case expression so that "Most Recent", "Default", and the wildcard (_) are
combined into a single arm (e.g., case "Most Recent" | "Default" | _: return
reviews.order_by("-created")) to remove duplication and make the intent explicit
while leaving behavior unchanged; locate the case statement in the method that
returns reviews ordering in models.py to apply this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tcf_website/models/models.py`:
- Around line 1339-1342: The match/case block that returns ordering for reviews
currently has duplicate branches for "Most Recent" and the default branch;
update the match arms in the function containing this case expression so that
"Most Recent", "Default", and the wildcard (_) are combined into a single arm
(e.g., case "Most Recent" | "Default" | _: return reviews.order_by("-created"))
to remove duplication and make the intent explicit while leaving behavior
unchanged; locate the case statement in the method that returns reviews ordering
in models.py to apply this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5637dd58-e297-440f-9174-d7d33a01f066

📥 Commits

Reviewing files that changed from the base of the PR and between c1052bc and 8d5df16.

📒 Files selected for processing (1)
  • tcf_website/models/models.py

@Jay-Lalwani Jay-Lalwani merged commit 3c00a16 into dev Mar 29, 2026
4 checks passed
@Jay-Lalwani Jay-Lalwani deleted the order-by-most-recent branch March 29, 2026 18:22
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.

2 participants