✨(backend) Order pinned documents by last updated at#2028
✨(backend) Order pinned documents by last updated at#2028lunika merged 1 commit intosuitenumerique:mainfrom
Conversation
a1e9e71 to
ac0c97a
Compare
Sort favorite_list results by updated_at property descending. Signed-off-by: Paul Vernin <paul.vernin@gmail.com>
ac0c97a to
ace831d
Compare
WalkthroughThis PR implements ordering of favorite (pinned) documents by their Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/backend/core/tests/documents/test_api_documents_favorite_list.py`:
- Around line 118-120: The test test_api_documents_favorite_list currently
asserts strict ordering on content by checking content[0], content[1],
content[2], which can be flaky because timestamps may collide; change these
assertions to verify membership only (e.g., compare sets of IDs or use assertIn
for each expected id) so the test asserts that the expected document ids
(access.document.id and children[0].id/children[1].id) are present in the
response without assuming order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bcd70718-9add-45e7-a5c5-28d6af67cd6f
📒 Files selected for processing (3)
CHANGELOG.mdsrc/backend/core/api/viewsets.pysrc/backend/core/tests/documents/test_api_documents_favorite_list.py
| assert content[0]["id"] == str(access.document.id) | ||
| assert content[1]["id"] == str(children[1].id) | ||
| assert content[2]["id"] == str(children[0].id) |
There was a problem hiding this comment.
Avoid strict ordering assertions in the non-order-specific test.
This test now asserts exact index order without controlling timestamps, so it can become flaky when updated_at values collide. Since ordering is already validated in test_api_document_favorite_list_sorted_by_updated_at, this test should only verify membership.
✅ Suggested test stabilization
- assert content[0]["id"] == str(access.document.id)
- assert content[1]["id"] == str(children[1].id)
- assert content[2]["id"] == str(children[0].id)
+ ids = {item["id"] for item in content}
+ assert ids == {
+ str(access.document.id),
+ str(children[0].id),
+ str(children[1].id),
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert content[0]["id"] == str(access.document.id) | |
| assert content[1]["id"] == str(children[1].id) | |
| assert content[2]["id"] == str(children[0].id) | |
| ids = {item["id"] for item in content} | |
| assert ids == { | |
| str(access.document.id), | |
| str(children[0].id), | |
| str(children[1].id), | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/backend/core/tests/documents/test_api_documents_favorite_list.py` around
lines 118 - 120, The test test_api_documents_favorite_list currently asserts
strict ordering on content by checking content[0], content[1], content[2], which
can be flaky because timestamps may collide; change these assertions to verify
membership only (e.g., compare sets of IDs or use assertIn for each expected id)
so the test asserts that the expected document ids (access.document.id and
children[0].id/children[1].id) are present in the response without assuming
order.
Purpose
Recording.2026-03-16.202548.1.mp4
Proposal
External contributions
Thank you for your contribution! 🎉
Please ensure the following items are checked before submitting your pull request:
git commit --signoff(DCO compliance)git commit -S)<gitmoji>(type) title description## [Unreleased]section (if noticeable change)