learning-unlimited/ESP-Website — pull request #1456 by benjaminjkraft (2014-11-04 05:42:09+00:00)
Title: Remove thousands of queries from the studentreg mainpage

@emannes noticed that the studentreg mainpage was doing as many as thousands of
queries to get data it didn't need. Now it doesn't.

In particular, it would compute, in a very inefficient way, the highest
priority level a user has in that timeblock (with zero being enrolled), and
then use that only to check whether the user had an enrolled class in that
timeblock. The view using the data in fact already had that information, so
the entire mess was unnecessary.

The issue was that the function ESPUser.getRegistrationPriority was getting
called for each timeblock, and it does a query for each section for which the
user has a StudentRegistration. That function is still inefficient, but the
other callers only call it once, so that should be less of an issue.

We may want to consider cherry-picking this to other sites in FCFS reg, since it cut off like 3s from studentreg load time for users with a reasonably large number of preferences for me. I did test that it works with the old lottery, but only briefly.