Bound Activity loads on ActivityParticipation admin forms - #178
Merged
Merged
Conversation
Stop loading every past Activity into the ActiveAdmin new/edit select. The form now queries a column-narrowed, LIMIT 200 coming and past collection and always keeps the assigned activity. Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
Activity collection loads bind LIMIT as ?, so assert the clause instead of a literal 200. Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ActivityParticipationsController#edit(and#new, same ActiveAdmin form) got slower in production because the activity dropdown loaded every past Activity withSELECT *and noLIMIT.AppSignal CSA Admin / production, Europe/Zurich week 7–14 Sep 2026:
ActivityParticipationsController#editclefdeschamps, rev6de5f427…, ~1.8–1.9s on 12 Sep ~15:21 CESTTrace
13f9da2263b7dce15f02c3d0c0f26b97(1899.9ms):active_admin/resource/edit→_form≈1719msComing activities used the same unbounded
SELECT *(cheap on that tenant). A follow-upWHERE id = ? LIMIT ?Activity Load and the member select remain; those are single-row / needed dropdown data, not the hotspot.Change
The form called
grouped_by_date(Activity), which instantiates the full past (and coming) relation for the select.It now uses
Activity.admin_form_collection:LIMIT 200id,date,start_time,end_time,places)No new frontend stack. Member collection is unchanged (needed for the member select; ~4.5ms in the trace).
Tests
Controller and model tests assert the form Activity queries stay bounded as activity count grows (
LIMIT, noSELECT *, nodescriptions/titles/place_urls), and that an assigned activity older than the limit remains selected.Locally:
bin/rails test test/models/activity_test.rb test/controllers/activity_participations_controller_test.rband RuboCop on the touched files are green.