Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBER-1143: additional skill parsing, increase timeout for filter #3933

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions plugins/recruit-resources/src/components/CreateCandidate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/recruit-resources/src/components/SkillsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
loc.path[3] = 'talents'
loc.path.length = 4
navigate(loc)
setTimeout(() => setFilterTag(tag), 50)
setTimeout(() => setFilterTag(tag), 200)
}
</script>

Expand Down