From 7f15f8028b41354335f86297437377bbb76c3dc6 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Wed, 6 May 2026 10:32:35 +0200 Subject: [PATCH] feat: update inventory queries to filter by userId for accurate recipe analysis --- backend/src/recipes/recipe-analysis.service.ts | 3 ++- flutter/lib/features/admin/data/admin_repository.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/recipes/recipe-analysis.service.ts b/backend/src/recipes/recipe-analysis.service.ts index ff9f8594..a4922719 100644 --- a/backend/src/recipes/recipe-analysis.service.ts +++ b/backend/src/recipes/recipe-analysis.service.ts @@ -82,6 +82,7 @@ export class RecipeAnalysisService { const pantryProductIds = new Set(pantryItems.map((p) => p.productId)); const userInventory = await this.prisma.inventoryItem.findMany({ + where: { userId }, select: { productId: true }, }); const availableProductIds = new Set([ @@ -153,7 +154,7 @@ export class RecipeAnalysisService { } const inventoryItems = await this.prisma.inventoryItem.findMany({ - where: { productId: ingredient.productId }, + where: { productId: ingredient.productId, userId }, select: { quantity: true, unit: true }, }); diff --git a/flutter/lib/features/admin/data/admin_repository.dart b/flutter/lib/features/admin/data/admin_repository.dart index be7abeeb..aa4ef06e 100644 --- a/flutter/lib/features/admin/data/admin_repository.dart +++ b/flutter/lib/features/admin/data/admin_repository.dart @@ -171,7 +171,7 @@ class AdminRepository { // ── Produkter ────────────────────────────────────────────────────────────── Future> listProducts() => - _getList(ProductApiPaths.list, AdminProduct.fromJson); + _getList(ProductApiPaths.mine, AdminProduct.fromJson); Future> listDeletedProducts() => _getList(ProductApiPaths.deleted, AdminProduct.fromJson);