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:
parent
7bb05d4987
commit
0603fe320c
1 changed files with 6 additions and 6 deletions
|
|
@ -464,18 +464,18 @@ class Category(NiceModel, MPTTModel):
|
|||
@cached_property
|
||||
def min_price(self) -> float:
|
||||
return (
|
||||
self.products.filter(
|
||||
is_active=True, stocks__is_active=True
|
||||
).aggregate(Min("stocks__price"))["stocks__price__min"]
|
||||
self.products.filter(is_active=True, stocks__is_active=True).aggregate(
|
||||
Min("stocks__price")
|
||||
)["stocks__price__min"]
|
||||
or 0.0
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def max_price(self) -> float:
|
||||
return (
|
||||
self.products.filter(
|
||||
is_active=True, stocks__is_active=True
|
||||
).aggregate(Max("stocks__price"))["stocks__price__max"]
|
||||
self.products.filter(is_active=True, stocks__is_active=True).aggregate(
|
||||
Max("stocks__price")
|
||||
)["stocks__price__max"]
|
||||
or 0.0
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue