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

Inventory performance #18

Merged
merged 4 commits into from
Apr 26, 2018
Merged

Conversation

notexactlyawe
Copy link
Contributor

I noticed that the load times for /inventory were around 2/3 seconds on my machine and so I investigated and found out that the issue was that the template called item.quantity for every item, each of which made two queries on the database. This pull request adds in queries at the inventory level to do the same job with fewer requests to the database.

The initial way I did the queries (ff47e60) actually changed the behaviour of the page as it only looked at requests that had been fulfilled without looking at those that had also been approved. cb0dfd2 changes this to fit with the current behaviour and looks at requests that are both approved and fulfilled.

There are also some whitespace changes in the below, since my editor was moaning at me about spaces at the end of lines.

I've written a more in-depth look at the issue available here.

Any comments or suggestions on this pull request, or the changes within are welcome!

When loading inventory, there was a large wait time for the page to
load due to the app making many times more requests to the database
than it needed to. This was because quantity was calculated with a
count for every item. I have changed it so that there is a single group
by count done in inventory.py that is then passed to templates cutting
the number of requests hugely
This is to check the correctness of ff47e6
Before it was returning how many items hadn't been released in a
fulfilled request, but the behaviour before was that it would tell how
many hadn't been approved. The new behaviour is the latter
@nmoroze nmoroze merged commit 3ae3b69 into techx:master Apr 26, 2018
@nmoroze
Copy link
Collaborator

nmoroze commented Apr 26, 2018

Just went through everything and looks great! Thanks so much :)

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.

2 participants