Skip to content

Comments

fix: eager load permissions and organisers in DashboardController#2503

Merged
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/dashboard-eager-loading
Feb 23, 2026
Merged

fix: eager load permissions and organisers in DashboardController#2503
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/dashboard-eager-loading

Conversation

@mroderick
Copy link
Collaborator

Summary

  • Adds :permissions and :organisers to eager loading in DashboardController
  • Changes from includes() to eager_load() for nested through-associations
  • Fixes N+1 queries on homepage (/)

Motivation

Bullet was reporting N+1 queries on the homepage. The view accesses event.organisers which requires the permissions join table to be eager loaded.

Analysis

  • Before: N+1 queries per event for organisers
  • After: Single query with JOIN on permissions table

Test Plan

  • All existing tests pass
  • Manual verification with Bullet shows no N+1 queries for organisers

@mroderick mroderick marked this pull request as ready for review February 21, 2026 15:06
Copy link
Collaborator

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Makes sense!

Motivation:
Bullet was reporting N+1 queries on the homepage (/). The view accesses
event.organisers which requires the permissions join table to be eager loaded.

Analysis:
- The all_events method loads Event and Workshop objects that need
  organisers and permissions preloaded
- Also fixed Meeting eager loading to include permissions
- Changed from includes() to eager_load() to handle nested through-associations
  (organisers goes through permissions)

Before: N+1 queries per event for organisers
After: Single query with JOIN on permissions table.
@mroderick mroderick force-pushed the fix/dashboard-eager-loading branch from d217e48 to ac423bb Compare February 23, 2026 16:05
@mroderick mroderick merged commit 44cedfd into codebar:master Feb 23, 2026
8 checks passed
@mroderick mroderick deleted the fix/dashboard-eager-loading branch February 23, 2026 16:16
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