Fixes: 1) Replace product_uuid with product_id in stock filtering queries to ensure compatibility.
Extra: Refactor annotations for consistency across `core/filters.py` and `core/graphene/schema.py`.
This commit is contained in:
parent
f646d5ab09
commit
d14d8e41db
2 changed files with 4 additions and 4 deletions
|
|
@ -276,8 +276,8 @@ class ProductFilter(FilterSet):
|
|||
|
||||
ordering_param = self.data.get("order_by", "")
|
||||
|
||||
stock_with_price = Stock.objects.filter(product_uuid=OuterRef("pk"), price__gt=0)
|
||||
stock_with_qty = Stock.objects.filter(product_uuid=OuterRef("pk"), quantity__gt=0)
|
||||
stock_with_price = Stock.objects.filter(product_id=OuterRef("pk"), price__gt=0)
|
||||
stock_with_qty = Stock.objects.filter(product_id=OuterRef("pk"), quantity__gt=0)
|
||||
|
||||
qs = qs.annotate(
|
||||
has_price=Exists(stock_with_price),
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ class Query(ObjectType):
|
|||
.prefetch_related("images", "stocks")
|
||||
)
|
||||
|
||||
stock_with_price = Stock.objects.filter(product_uuid=OuterRef("pk"), price__gt=0)
|
||||
stock_with_qty = Stock.objects.filter(product_uuid=OuterRef("pk"), quantity__gt=0)
|
||||
stock_with_price = Stock.objects.filter(product_id=OuterRef("pk"), price__gt=0)
|
||||
stock_with_qty = Stock.objects.filter(product_id=OuterRef("pk"), quantity__gt=0)
|
||||
|
||||
return (
|
||||
base_qs.annotate(
|
||||
|
|
|
|||
Loading…
Reference in a new issue