2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-12 07:54:14 +00:00

Reduce response time for stock list

Initial time - 6.2s
After prefetch - 4.3s
This commit is contained in:
Oliver Walters
2019-05-20 08:44:52 +10:00
parent 5055226490
commit fc75ab7420
3 changed files with 13 additions and 0 deletions

View File

@ -282,6 +282,9 @@ class StockList(generics.ListCreateAPIView):
if supplier_id:
stock_list = stock_list.filter(supplier_part__supplier=supplier_id)
# Pre-fetch related objects for better response time
stock_list = self.get_serializer_class().setup_eager_loading(stock_list)
return stock_list
serializer_class = StockItemSerializer