Skip to content

Query sidebar directs and shared rooms separately - #318

Open
thomasklemm wants to merge 5 commits into
basecamp:mainfrom
thomasklemm:cursor/split-sidebar-membership-queries-8545
Open

thomasklemm wants to merge 5 commits into
basecamp:mainfrom
thomasklemm:cursor/split-sidebar-membership-queries-8545

Conversation

@thomasklemm

Copy link
Copy Markdown

GET /users/me/sidebar loaded every visible membership, split directs in Ruby, then re-sorted them by updated_at.

Directs and shared rooms are now two queries:

  • directs: merge(Room.directs), ordered by recency
  • shared: with_ordered_room.without_direct_rooms

Fixes #307

cursoragent and others added 3 commits October 5, 2026 12:35
Load visible direct memberships ordered by room recency and other
rooms ordered by name, instead of hydrating every membership and
splitting them in Ruby.

Fixes basecamp#307.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Chaining without_direct_rooms with with_ordered_room joined rooms as
`room` while still ordering on `rooms.name`. Load shared rooms in one
scope instead.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Directs merge Room.directs and order by recency. Shared rooms reuse
with_ordered_room and without_direct_rooms, with the STI filter coming
from Room.without_directs so the join alias stays rooms.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approved

The focused query refactor preserves behavior and is covered by ordering tests.

Review effort: Balanced
Findings: None

What changed in this PR

Separates direct and shared sidebar memberships into dedicated SQL queries while preserving their respective sort orders.

Changes:

  • Queries directs by room recency.
  • Queries shared rooms alphabetically.
  • Adds integration tests for both orderings.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
app/​controllers/​users/​sidebars_controller.rb Loads direct and shared memberships separately.
app/​models/​membership.rb Adds direct filtering and reuses room scopes.
test/​controllers/​users/​sidebars_controller_test.rb Verifies direct and shared ordering.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

thomasklemm added a commit to roundhouse-rb/once-campfire that referenced this pull request Oct 5, 2026
From thomasklemm:cursor/split-sidebar-membership-queries-8545 (upstream PR state at merge: OPEN).
…r-membership-queries-8545

Co-authored-by: Thomas Klemm <github@tklemm.eu>
thomasklemm added a commit to roundhouse-rb/once-campfire that referenced this pull request Oct 5, 2026
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.

Sidebar loads every visible membership, then splits directs in Ruby

3 participants