Add negative label filtering for cards

This commit is contained in:
Symon
2026-06-05 16:43:45 +03:00
parent 856768c45e
commit 55d0e2f877
23 changed files with 638 additions and 235 deletions
+21 -2
View File
@@ -38,8 +38,13 @@ const getByListId = async (listId, { exceptIdOrIds, sort = ['position', 'id'] }
return defaultFind(criteria, { sort });
};
const getByEndlessListId = async (listId, { before, search, userIds, labelIds }) => {
if (search || userIds || labelIds) {
const getByEndlessListId = async (
listId,
{ before, search, userIds, labelIds, excludedLabelIds },
) => {
const hasExcludedLabelIds = excludedLabelIds && excludedLabelIds.length > 0;
if (search || userIds || labelIds || hasExcludedLabelIds) {
if (userIds && userIds.length === 0) {
return [];
}
@@ -108,6 +113,20 @@ const getByEndlessListId = async (listId, { before, search, userIds, labelIds })
query += ` AND card_label.label_id IN (${inValues.join(', ')})`;
}
if (hasExcludedLabelIds) {
const inValues = excludedLabelIds.map((labelId) => {
queryValues.push(labelId);
return `$${queryValues.length}`;
});
query += ` AND NOT EXISTS (
SELECT 1
FROM card_label AS excluded_card_label
WHERE excluded_card_label.card_id = card.id
AND excluded_card_label.label_id IN (${inValues.join(', ')})
)`;
}
query += ` LIMIT ${LIMIT}`;
let queryResult;