Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize person detail page #1117

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

antidipyramid
Copy link
Collaborator

@antidipyramid antidipyramid commented Jun 7, 2024

Overview

See title. Locally, I saw database calls on person detail pages reduce by about half.

Notes

Evaluating the Queryset returned by LAMetroPerson.committee_sponsorships on Heroku takes anywhere from several minutes to sometimes 10+ seconds (along with spiking memory usage). Since we're only evaluating the Queryset once, I dropped in an iterator to see if the lack of caching can improve the performance.

Connects #1109

Testing Instructions

  • Verify tests pass

@antidipyramid antidipyramid marked this pull request as ready for review June 7, 2024 14:50
@fgregg fgregg temporarily deployed to la-metro-cou-feature-11-ognmqt June 7, 2024 14:57 Inactive
@antidipyramid antidipyramid marked this pull request as draft June 7, 2024 15:00
lametro/views.py Outdated
@@ -701,13 +701,15 @@ def get_context_data(self, **kwargs):
except AttributeError:
context["map_geojson"] = None

if person.committee_sponsorships:
context["sponsored_legislation"] = person.committee_sponsorships
sponsored_legislation = list(person.committee_sponsorships.iterator())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Beautiful.

@antidipyramid antidipyramid temporarily deployed to la-metro-cou-feature-11-ognmqt June 11, 2024 13:10 Inactive
@antidipyramid antidipyramid temporarily deployed to la-metro-cou-feature-11-ognmqt June 14, 2024 14:19 Inactive
@antidipyramid antidipyramid temporarily deployed to la-metro-cou-feature-11-ognmqt June 14, 2024 14:28 Inactive
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