Skip to content

[ENGAGE-6323] Fix pin otimization#799

Open
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
fix/pin-otimization
Open

[ENGAGE-6323] Fix pin otimization#799
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
fix/pin-otimization

Conversation

@MarcusviniciusLsantos
Copy link
Copy Markdown
Contributor

@MarcusviniciusLsantos MarcusviniciusLsantos commented Dec 26, 2025

Note

Improves the rooms list performance and preserves expected pin behavior.

  • Reworks RoomViewset._list_with_optimized_pin_order to filter first, then:
    • Fetch pinned room IDs for the target user, union with filtered room IDs
    • Annotate only needed rooms with is_pinned and latest pin_created_on
    • Apply ordering with pins first, then existing secondary sort
  • Removes unnecessary intermediate subqueries/fields and avoids O(N) annotations
  • Tests:
    • Tighten query cap from 400 to ≤50 for large lists
    • Add test ensuring pinned rooms are always included (even when not matching filters), appear first, and maintain low query count under filters

Written by Cursor Bugbot for commit 34b6d62. This will update automatically on new commits. Configure here.

… more efficiently, reducing unnecessary database queries and improving performance.
- Introduced a new test to verify that filtering occurs before annotating in the optimized pin version, ensuring better performance with large datasets.
- Updated existing tests to reflect the expected reduction in query count, emphasizing the importance of efficient database interactions.
- Added assertions to confirm correct filtering and ordering of active pinned rooms in the response.
- Cleaned up whitespace in the test code for better readability.
- Ensured assertions for query counts are formatted consistently.
- Verified that filtering and ordering of active pinned rooms are correctly tested, maintaining performance expectations.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

- Updated test documentation to specify that pinned rooms are always included in results, regardless of filters, aligning with legacy behavior.
- Adjusted assertions to ensure both active and inactive pinned rooms are correctly included in the response, maintaining expected order.
- Improved clarity on the sorting of pinned rooms before regular active rooms in the results.
- Cleaned up unnecessary whitespace in the test code to enhance readability.
- Ensured that the documentation and assertions remain clear and consistent, maintaining focus on the behavior of pinned rooms in the results.
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.

1 participant