From 18d73dea4f0649dded00cb6a6dda58e82ab0cc82 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Fri, 3 Nov 2023 02:37:37 +0500 Subject: [PATCH 1/2] UBER-1143: add script to parse skills Signed-off-by: Vyacheslav Tumanov --- .../src/components/CreateCandidate.svelte | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/plugins/recruit-resources/src/components/CreateCandidate.svelte b/plugins/recruit-resources/src/components/CreateCandidate.svelte index 36d5580cd5d..277c2ed0e2a 100644 --- a/plugins/recruit-resources/src/components/CreateCandidate.svelte +++ b/plugins/recruit-resources/src/components/CreateCandidate.svelte @@ -346,9 +346,55 @@ const categoriesMap = toIdMap(categories) const newSkills: TagReference[] = [] - + const formattedSkills = (doc.skills.map((s) => s.toLowerCase()) ?? []).filter( + (skill) => !namedElements.has(skill) + ) + const refactoredSkills = [] + if (formattedSkills.length > 0) { + const existingTags = Array.from(namedElements.keys()).filter((x) => x.length > 2) + const regex = /\S+(?:[-+]\S+)+/g + const regexForEmpty = /^((?![a-zA-Zа-яА-Я]).)*$/g + for (let sk of formattedSkills) { + sk = sk.toLowerCase() + const toReplace = [...new Set([...existingTags, ...refactoredSkills])] + .filter((s) => sk.includes(s)) + .sort((a, b) => b.length - a.length) + if (toReplace.length > 0) { + for (const replacing of toReplace) { + if (namedElements.has(replacing)) { + refactoredSkills.push(replacing) + sk = sk.replace(replacing, '').trim() + } + } + } + if (sk.includes(' ')) { + const skSplit = sk.split(' ') + for (const spl of skSplit) { + const fixedTitle = regex.test(spl) ? spl.replaceAll(/[+-]/g, '') : spl + if (namedElements.has(fixedTitle)) { + refactoredSkills.push(fixedTitle) + sk = sk.replace(spl, '').trim() + } + if ([...doc.skills, ...refactoredSkills].includes(fixedTitle)) { + sk = sk.replace(spl, '').trim() + } + } + } + if (regex.test(sk)) { + const fixedTitle = sk.replaceAll(/[+-]/g, '') + if (namedElements.has(fixedTitle)) { + refactoredSkills.push(fixedTitle) + sk = '' + } + } + if (!regexForEmpty.test(sk) && !refactoredSkills.includes(sk)) { + refactoredSkills.push(sk) + } + } + } + const skillsToAdd = [...new Set([...doc.skills.map((s) => s.toLowerCase()), ...refactoredSkills])] // Create missing tag elemnts - for (const s of doc.skills ?? []) { + for (const s of skillsToAdd) { const title = s.trim().toLowerCase() let e = namedElements.get(title) if (e === undefined && shouldCreateNewSkills) { From f4c6aa2b33287c8959232afba964e2a8cd470083 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Fri, 3 Nov 2023 02:38:04 +0500 Subject: [PATCH 2/2] UBER-1143: increase timeout in case of slow loading Signed-off-by: Vyacheslav Tumanov --- plugins/recruit-resources/src/components/SkillsView.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/recruit-resources/src/components/SkillsView.svelte b/plugins/recruit-resources/src/components/SkillsView.svelte index 47aad435191..e20057a0cce 100644 --- a/plugins/recruit-resources/src/components/SkillsView.svelte +++ b/plugins/recruit-resources/src/components/SkillsView.svelte @@ -28,7 +28,7 @@ loc.path[3] = 'talents' loc.path.length = 4 navigate(loc) - setTimeout(() => setFilterTag(tag), 50) + setTimeout(() => setFilterTag(tag), 200) }