mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-24 18:14:22 +00:00
Optimized last operations on counters
This commit is contained in:
parent
67af1485b3
commit
06eecfce40
@ -1173,12 +1173,16 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
threshold = timezone.now() - timedelta(
|
threshold = timezone.now() - timedelta(
|
||||||
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
|
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
|
||||||
)
|
)
|
||||||
kwargs["last_refillings"] = self.object.refillings.filter(
|
kwargs["last_refillings"] = (
|
||||||
date__gte=threshold
|
self.object.refillings.filter(date__gte=threshold)
|
||||||
).order_by("-id")[:20]
|
.select_related("operator", "customer__user")
|
||||||
kwargs["last_sellings"] = self.object.sellings.filter(
|
.order_by("-id")[:20]
|
||||||
date__gte=threshold
|
)
|
||||||
).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
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user