Skip to content

Cap or paginate the workshop list in DashboardQuery.upcoming_events_for_user #3093

Open

Description

@mroderick

DashboardQuery.upcoming_events_for_user loads every upcoming workshop from the member's chapters, with no limit and no pagination:

def self.chapter_workshops_for(member)
  Workshop.upcoming
          .eager_load(:chapter, :sponsors, :organisers, :permissions)
          .preload(workshop_host: :sponsor)
          .where(chapter: member.chapters)
          .to_a
end

The homepage query in the same class caps at MAX_WORKSHOP_QUERY = 10 (upcoming_workshops), and /dashboard renders every card it receives (app/views/dashboard/dashboard.html.haml renders EventCardComponent.with_collection for each date group).

Exposure today

Measured against the local production snapshot (codebar_production_dump):

  • busiest chapter runs 5 workshops in a month, p95 = 2
  • one member belongs to 40 chapters, but no member has more than 5 upcoming workshop cards
  • 54 chapters exist, 4 have upcoming workshops in the snapshot

So no member is affected right now. The risk is a member subscribed to several busy chapters as workshop volume grows, or a chapter that starts scheduling further ahead.

Options

  • cap the chapter-workshops branch at MAX_WORKSHOP_QUERY, matching the homepage query
  • paginate the dashboard card list

A cap changes what members see, so this needs a product decision rather than a pure refactor.

Found while reviewing #3074. The query existed before that PR and moved unchanged, so this predates it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions