style(models): reformat price aggregation queries for readability

Improves code readability by restructuring the `min_price` and `max_price` methods into a more concise and consistent format. No functional changes introduced.
This commit is contained in:
Egor Pavlovich Gorbunov 2026-02-27 21:58:56 +03:00
parent 7bb05d4987
commit 0603fe320c

View file

@ -464,18 +464,18 @@ class Category(NiceModel, MPTTModel):
@cached_property @cached_property
def min_price(self) -> float: def min_price(self) -> float:
return ( return (
self.products.filter( self.products.filter(is_active=True, stocks__is_active=True).aggregate(
is_active=True, stocks__is_active=True Min("stocks__price")
).aggregate(Min("stocks__price"))["stocks__price__min"] )["stocks__price__min"]
or 0.0 or 0.0
) )
@cached_property @cached_property
def max_price(self) -> float: def max_price(self) -> float:
return ( return (
self.products.filter( self.products.filter(is_active=True, stocks__is_active=True).aggregate(
is_active=True, stocks__is_active=True Max("stocks__price")
).aggregate(Max("stocks__price"))["stocks__price__max"] )["stocks__price__max"]
or 0.0 or 0.0
) )