perf(events): skip RSVP and photo hydration on calendar reads - #1411
Merged
Conversation
Staging workers grew tens of MB per calendar load and event open because list/detail hydrated every RSVP, invitee, and presigned photo. Count in SQL, prefetch only the viewer's RSVP, and skip guest photos the UI never shows.
Keep list RSVPs on _viewer_rsvps so the relation is not a filtered cache, honor existing prefetches in _event_out, and check invite-only membership with exists() instead of loading every invitee.
Calendar list and non-host detail never render invited names, so counting invitees for everyone was wasted work. Can't-go still counts as RSVP'd — those viewers can see who is going. Host-removed RSVPs stay hidden.
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.
Overview
Staging gunicorn workers grew tens of MB each time someone opened the calendar or a new event. The list endpoint hydrated every RSVP and invitee and presigned photos the calendar never renders; event detail did the same for viewers who cannot see the guest list.
This keeps the same JSON shape (list
photo_url/created_by_photo_url/co_host_photo_urlsstay in the schema as empty values). Counts come from SQL subqueries. List prefetches only the viewer's RSVP. Detail loads guests and invitees only when the viewer is allowed to see them. Hosts and people with an active RSVP still get the full guest list.Test plan
tests/test_event_list_memory.py— list does not instantiate every RSVP; photo fields empty;my_rsvpstill works; invite-only stays hidden; detail skips RSVP hydration when guests are hiddenmake agent-lint/make agent-typecheck/make agent-complexity/ schema checksmake agent-frontend-ci(no frontend changes)mainon 40 events / 1,001 RSVPs: listmedia_path200→0 and RSVP inits 1,001→0; stranger detail RSVP inits 26→0 andmedia_path31→5; host/attendee detail unchangedPDA_MEMORY_PROFILE=1, open the calendar then several events as a non-guest and confirm listmedia_path_callsis ~0 and RSS no longer jumps tens of MB per new event🤖 Created with Cursor