From a7a0daaf82542ba95085f25787dc65dc82fe2346 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 19 Jan 2026 13:14:13 +0100 Subject: [PATCH] Enhance VocabService to combine AND conditions in query filtering - Updated VocabService to combine AND conditions with direct where properties when both are present, improving query accuracy. - Added comments for better understanding of the new logic and its implications on course retrieval. --- backend/services/vocabService.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/services/vocabService.js b/backend/services/vocabService.js index ccdf945..ff42d9c 100644 --- a/backend/services/vocabService.js +++ b/backend/services/vocabService.js @@ -606,7 +606,19 @@ export default class VocabService { } // Kombiniere alle AND-Bedingungen + // Wenn sowohl andConditions als auch direkte where-Eigenschaften existieren, + // müssen sie kombiniert werden if (andConditions.length > 0) { + // Wenn where bereits direkte Eigenschaften hat, füge sie zu andConditions hinzu + const directWhereProps = Object.keys(where).filter(key => key !== Op.and && key !== Op.or); + if (directWhereProps.length > 0) { + const directWhere = {}; + for (const key of directWhereProps) { + directWhere[key] = where[key]; + delete where[key]; + } + andConditions.push(directWhere); + } where[Op.and] = andConditions; } @@ -621,7 +633,9 @@ export default class VocabService { languageId, nativeLanguageId, search, - where: JSON.stringify(where, null, 2) + where: JSON.stringify(where, null, 2), + includePublic, + includeOwn }); const coursesData = courses.map(c => c.get({ plain: true }));