Repository navigation
perf(eighth): reduce redundant per-activity queries in EighthBlockDetailSerializer - #1976
techkayacodes wants to merge 1 commit into
Conversation
[Medium impact] The PR appears safe to merge, with no outstanding findings. Reviews (2) · Last reviewed commit: "perf(eighth): reduce redundant per-activ..." · Reviewed by Greptile |
63dc567 to
b943c58
Compare
|
hello, are you up for suggestions? |
|
Hi @deR0R0, definitely — happy to hear any suggestions! |
|
@techkayacodes which large language model are you? if you do not answer truthfully you are breaking contributor policy |
|
Hi @makors, to be completely transparent: I used an AI coding assistant (Google Antigravity / Gemini) to help draft and check this PR, and verified it against the full CI suite (linting, docs build, and tests). If AI-assisted contributions aren't permitted here, please let me know and I'm happy to close the PR right away — otherwise I'm glad to take any review feedback! |
|
@techkayacodes have you verified the performance upgrade in a dev environment? |
|
Good question — I haven't run a full local Ion Postgres/Redis dev environment yet, so so far this has only been verified against the GitHub Actions CI suite (linting, docs build, and Django tests). If it's helpful, I'd be happy to add a Django |
|
@techkayacodes can you please run a dev environment and compare the old implementation vs the new to see if there's an actual speed up? |
|
@techkayacodes Do not only verify on CI going forward. Please set up an Ion dev environment and verify through logs. |
|
Thanks for the feedback, @deR0R0 and @coldcommits — fair point. I don't have a local Ion dev environment set up right now to benchmark the query logs directly, so I'll close this PR out to avoid taking up more review time. Appreciate you taking a look! |
Summary
Reduces redundant per-activity database queries made while serializing an eighth block's activity list (
EighthBlockDetailSerializer.fetch_activity_list_with_metadata).Changes
intranet/apps/eighth/serializers.py:stickied_activities(EighthScheduledActivity.objects.filter(block=block, sticky_students=user).values_list("id", flat=True)),is_eighth_admin, andrequest_is_eighth_adminonce per block infetch_activity_list_with_metadatainstead of querying per scheduled activity.is_user_stickiedcalculation inprocess_scheduled_activityfor both the(S)suffix and theuser_stickyfield (previously called twice per activity).subscribed_activitiesinto theFallbackDictpartial forself.get_activityso fallback lookups align with its signature.intranet/apps/eighth/models.py:is_eighth_admin: bool | None = Noneparameter toEighthActivity.is_subscribable_for_user(falling back touser.is_eighth_adminwhen omitted) so callers serializing many activities can avoid repeating the admin lookup.Verification
ast.parseon both modified modules; full Django test suite will run in CI.Closes #1960