Отбор работ подрядчика: совпадение по началу слова (wall не находит Drywall)
All checks were successful
ci / test (push) Successful in 32s
ci / deploy (push) Successful in 2m24s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 22:59:54 +03:00
parent 2987e8f139
commit 83f28625dd

View File

@@ -138,12 +138,12 @@ export function pgResolveStore(db: Queryable): ResolveStore {
return rows.map((r) => ({ jobId: String(r.job_id), name: String(r.name) }));
},
async vendorAssignments(jobId, terms) {
const like = terms.map((t) => `%${t.replace(/[%_\\]/g, "")}%`);
const like = terms.map((t) => `\\m${t.replace(/[^a-z0-9а-яё]/g, "")}`); // начало слова: "wall" не находит "Drywall"
const { rows } = await db.query(
`select t.id as task_id, t.name as task_name, a.membership_id
from jt_task t join jt_task_assignment a on a.task_id = t.id join jt_membership m on m.id = a.membership_id and m.role = 'Vendor'
where t.job_id = $1 and not t.is_deleted and not t.is_todo and not t.is_group and coalesce(t.progress, 0) < 1
and ($2::text[] = '{}' or t.name ilike any($2::text[]))
and ($2::text[] = '{}' or t.name ~* any($2::text[]))
order by t.start_date nulls last, t.name`,
[jobId, like],
);