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.
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user