harvard-lil / perma

Indelible links
411 stars 70 forks source link

Retrieve sponsored users with a non-standard strategy for improved performance. #3435

Closed rebeccacremona closed 8 months ago

rebeccacremona commented 8 months ago

See ENG-181 and https://github.com/harvard-lil/perma/issues/3276.

This page, when viewed as an admin, consistently gives us a hard time.

Every other page of this type reuses the list_users_in_group method... which just isn't working out here: the SQL is just not very efficient. So, this PR adds a custom method for retrieving sponsored users and handing them off to the template with the necessary related objects pre-fetched.

There is some duplication of code between list_users_in_group and the new method, but I think it's not worth it to restructure at this time: these views are likely being completely redesigned soon anyway.

codecov[bot] commented 8 months ago

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (896bc1c) 69.84% compared to head (274470f) 69.85%. Report is 5 commits behind head on develop.

Files Patch % Lines
perma_web/perma/views/user_management.py 83.33% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3435 +/- ## ======================================== Coverage 69.84% 69.85% ======================================== Files 52 52 Lines 6620 6655 +35 ======================================== + Hits 4624 4649 +25 - Misses 1996 2006 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.