mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Merge pull request #851 from ae-utbm/841-sales-selection-performance
841 sales selection performance
This commit is contained in:
commit
3f2327dee4
@ -1173,12 +1173,16 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user