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