Skip to content

Commit

Permalink
Merge pull request #851 from ae-utbm/841-sales-selection-performance
Browse files Browse the repository at this point in the history
841 sales selection performance
  • Loading branch information
imperosol authored Sep 30, 2024
2 parents 67af148 + 06eecfc commit 3f2327d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions counter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,16 @@ def get_context_data(self, **kwargs):
threshold = timezone.now() - timedelta(
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
)
kwargs["last_refillings"] = self.object.refillings.filter(
date__gte=threshold
).order_by("-id")[:20]
kwargs["last_sellings"] = self.object.sellings.filter(
date__gte=threshold
).order_by("-id")[:20]
kwargs["last_refillings"] = (
self.object.refillings.filter(date__gte=threshold)
.select_related("operator", "customer__user")
.order_by("-id")[:20]
)
kwargs["last_sellings"] = (
self.object.sellings.filter(date__gte=threshold)
.select_related("seller", "customer__user")
.order_by("-id")[:20]
)
return kwargs


Expand Down

0 comments on commit 3f2327d

Please sign in to comment.