This commit is contained in:
2026-09-12 07:28:24 +02:00
parent b319a5aec2
commit 217f1be72d
7 changed files with 93 additions and 22 deletions
+20 -6
View File
@@ -2533,7 +2533,8 @@ const f0cklib = {
exclude,
user_id,
is_admin,
mime
mime,
strict = false
} = {}) => {
if (!tag || !tag.trim()) return { items: [], total: 0 };
@@ -2561,14 +2562,27 @@ const f0cklib = {
: db``;
const terms = tag.split(',').map(t => t.trim()).filter(Boolean);
const tagConditions = terms.map(term => {
return db`and items.id in (
const isStrict = !!strict || (tag && tag.includes(','));
let tagConditions;
if (isStrict) {
tagConditions = terms.length > 0 ? [db`and items.id in (
select ta.item_id
from tags_assign ta
join tags t on t.id = ta.tag_id
where t.normalized like '%' || slugify(${term}) || '%'
)`;
});
where t.normalized = ANY(ARRAY(SELECT slugify(x) FROM unnest(${terms}::text[]) AS x))
group by ta.item_id
having count(distinct t.normalized) = ${terms.length}
)`] : [];
} else {
tagConditions = terms.map(term => {
return db`and items.id in (
select ta.item_id
from tags_assign ta
join tags t on t.id = ta.tag_id
where t.normalized like '%' || slugify(${term}) || '%'
)`;
});
}
const isDesc = String(order).toLowerCase() === 'desc';
const sortOrderItems = isDesc ? db`items.id desc` : db`items.id asc`;