fix(api): avoid distinct on json product fields in shopping suggestions
This commit is contained in:
parent
fecfa0b9e4
commit
cebea2ac86
2 changed files with 21 additions and 4 deletions
|
|
@ -1082,12 +1082,12 @@ def suggest_shopping(session: Session = Depends(get_session)):
|
|||
raise HTTPException(status_code=502, detail=f"LLM returned invalid JSON: {e}")
|
||||
|
||||
# Get products with inventory (those user already owns)
|
||||
products_with_inventory = session.exec(
|
||||
select(Product).join(ProductInventory).distinct()
|
||||
products_with_inventory_ids = session.exec(
|
||||
select(ProductInventory.product_id).distinct()
|
||||
).all()
|
||||
|
||||
shopping_context = ShoppingValidationContext(
|
||||
owned_product_ids=set(p.id for p in products_with_inventory),
|
||||
owned_product_ids=set(products_with_inventory_ids),
|
||||
valid_categories=set(ProductCategory),
|
||||
valid_targets=set(SkinConcern),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue