mirror of
https://github.com/hempyhemp/hh-auto-reply.git
synced 2026-06-08 18:04:57 +00:00
⚠️ fix(scraper): останавливает выполнение при 10 подряд пропущенных вакансий
All checks were successful
Deploy / deploy (push) Successful in 50s
All checks were successful
Deploy / deploy (push) Successful in 50s
This commit is contained in:
@@ -334,9 +334,16 @@ export async function applyToJobs(
|
|||||||
)
|
)
|
||||||
|
|
||||||
let appliedCount = 0
|
let appliedCount = 0
|
||||||
|
let consecutiveSkips = 0
|
||||||
|
const MAX_CONSECUTIVE_SKIPS = 10
|
||||||
for (const vacancy of vacancies) {
|
for (const vacancy of vacancies) {
|
||||||
if (appliedCount >= maxApplies)
|
if (appliedCount >= maxApplies)
|
||||||
break
|
break
|
||||||
|
if (consecutiveSkips >= MAX_CONSECUTIVE_SKIPS) {
|
||||||
|
log.warn(`Остановлено: ${MAX_CONSECUTIVE_SKIPS} пропусков подряд`)
|
||||||
|
await keep(`⚠️ Остановлено: ${MAX_CONSECUTIVE_SKIPS} вакансий подряд пропущено`)
|
||||||
|
break
|
||||||
|
}
|
||||||
const ref: VacancyRef = { title: vacancy.title, href: vacancy.href }
|
const ref: VacancyRef = { title: vacancy.title, href: vacancy.href }
|
||||||
|
|
||||||
if (knownSkipped.has(vacancy.href)) {
|
if (knownSkipped.has(vacancy.href)) {
|
||||||
@@ -355,12 +362,16 @@ export async function applyToJobs(
|
|||||||
|
|
||||||
if (!description) {
|
if (!description) {
|
||||||
results.skipped.push(ref)
|
results.skipped.push(ref)
|
||||||
|
appliedCount++
|
||||||
|
consecutiveSkips++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyBtn = await page.$('[data-qa="vacancy-response-link-top"]')
|
const applyBtn = await page.$('[data-qa="vacancy-response-link-top"]')
|
||||||
if (!applyBtn) {
|
if (!applyBtn) {
|
||||||
results.skipped.push(vacancy)
|
results.skipped.push(vacancy)
|
||||||
|
appliedCount++
|
||||||
|
consecutiveSkips++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,8 +383,11 @@ export async function applyToJobs(
|
|||||||
if (relocationConfirm)
|
if (relocationConfirm)
|
||||||
await relocationConfirm.click()
|
await relocationConfirm.click()
|
||||||
|
|
||||||
if (await skipIfQuestionnaire(page, vacancy, ref, chatId, status, results))
|
if (await skipIfQuestionnaire(page, vacancy, ref, chatId, status, results)) {
|
||||||
|
appliedCount++
|
||||||
|
consecutiveSkips++
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('[LetterDebug]:', '\nresume: ', resume.data, '\ndescription: ', description, '\nprompt: ', user!.prompt)
|
// console.log('[LetterDebug]:', '\nresume: ', resume.data, '\ndescription: ', description, '\nprompt: ', user!.prompt)
|
||||||
await keep(`✍️ Генерирую письмо: ${vacancy.title}`)
|
await keep(`✍️ Генерирую письмо: ${vacancy.title}`)
|
||||||
@@ -487,6 +501,7 @@ export async function applyToJobs(
|
|||||||
|
|
||||||
results.applied.push(ref)
|
results.applied.push(ref)
|
||||||
appliedCount++
|
appliedCount++
|
||||||
|
consecutiveSkips = 0
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
results.errors.push({ ...ref, message: (err as Error).message })
|
results.errors.push({ ...ref, message: (err as Error).message })
|
||||||
|
|||||||
Reference in New Issue
Block a user