From 52163342c37677082d56d54c62b39cd3cf316341 Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sun, 29 Jun 2025 14:48:40 +0800 Subject: [PATCH] add jobDetailRegExpMatchLogic option related flow in core script --- .../geek-auto-start-chat-with-boss/index.mjs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/geek-auto-start-chat-with-boss/index.mjs b/packages/geek-auto-start-chat-with-boss/index.mjs index f433826..66a224d 100644 --- a/packages/geek-auto-start-chat-with-boss/index.mjs +++ b/packages/geek-auto-start-chat-with-boss/index.mjs @@ -16,7 +16,7 @@ import { calculateTotalCombinations, combineFiltersWithConstraintsGenerator } fr import { default as jobFilterConditions } from './internal-config/job-filter-conditions-20241002.json' import { default as rawIndustryFilterExemption } from './internal-config/job-filter-industry-filter-exemption-20241002.json' import { ChatStartupFrom } from '@geekgeekrun/sqlite-plugin/dist/entity/ChatStartupLog' -import { MarkAsNotSuitReason, MarkAsNotSuitOp, StrategyScopeOptionWhenMarkJobNotMatch, SalaryCalculateWay } from '@geekgeekrun/sqlite-plugin/dist/enums' +import { MarkAsNotSuitReason, MarkAsNotSuitOp, StrategyScopeOptionWhenMarkJobNotMatch, SalaryCalculateWay, JobDetailRegExpMatchLogic } from '@geekgeekrun/sqlite-plugin/dist/enums' import { activeDescList } from './constant.mjs' import { parseSalary } from "@geekgeekrun/sqlite-plugin/dist/utils/parser" const jobFilterConditionsMapByCode = {} @@ -99,6 +99,8 @@ const expectWorkExpList = readConfigFile('boss.json').expectWorkExpList ?? [] const expectWorkExpNotMatchStrategy = readConfigFile('boss.json').expectWorkExpNotMatchStrategy ?? MarkAsNotSuitOp.NO_OP const strategyScopeOptionWhenMarkJobWorkExpNotMatch = readConfigFile('boss.json').strategyScopeOptionWhenMarkJobWorkExpNotMatch ?? StrategyScopeOptionWhenMarkJobNotMatch.ONLY_COMPANY_MATCHED_JOB +let jobDetailRegExpMatchLogic = readConfigFile('boss.json').jobDetailRegExpMatchLogic ?? JobDetailRegExpMatchLogic.EVERY + const markAsNotActiveSelectedTimeRange = (() => { let n = readConfigFile('boss.json').markAsNotActiveSelectedTimeRange if ( @@ -132,6 +134,16 @@ if ( expectJobDescRegExpStr = expectJobRegExpStr } +if ( + [ + expectJobNameRegExpStr, + expectJobTypeRegExpStr, + expectJobDescRegExpStr, + ].map(it => Boolean(it?.trim())).every(it => !it) +) { + jobDetailRegExpMatchLogic = JobDetailRegExpMatchLogic.EVERY +} + const localStoragePageUrl = `https://www.zhipin.com/desktop/` const recommendJobPageUrl = `https://www.zhipin.com/web/geek/jobs` @@ -262,8 +274,8 @@ async function markJobAsNotSuitInRecommendPage (reasonCode) { return result } -export function testIfJobTitleOrDescriptionSuit (jobInfo) { - let isJobNameSuit = true +export function testIfJobTitleOrDescriptionSuit (jobInfo, matchLogic) { + let isJobNameSuit = matchLogic === JobDetailRegExpMatchLogic.SOME ? false : true try { if (expectJobNameRegExpStr.trim()) { const regExp = new RegExp(expectJobNameRegExpStr, 'i') @@ -271,7 +283,7 @@ export function testIfJobTitleOrDescriptionSuit (jobInfo) { } } catch { } - let isJobTypeSuit = true + let isJobTypeSuit = matchLogic === JobDetailRegExpMatchLogic.SOME ? false : true try { if (expectJobTypeRegExpStr.trim()) { const regExp = new RegExp(expectJobTypeRegExpStr, 'i') @@ -279,7 +291,7 @@ export function testIfJobTitleOrDescriptionSuit (jobInfo) { } } catch { } - let isJobDescSuit = true + let isJobDescSuit = matchLogic === JobDetailRegExpMatchLogic.SOME ? false : true try { if (expectJobDescRegExpStr.trim()) { const regExp = new RegExp(expectJobDescRegExpStr, 'i') @@ -287,7 +299,12 @@ export function testIfJobTitleOrDescriptionSuit (jobInfo) { } } catch { } - return isJobNameSuit && isJobTypeSuit && isJobDescSuit + if (matchLogic === JobDetailRegExpMatchLogic.SOME) { + return isJobNameSuit || isJobTypeSuit || isJobDescSuit + } + else { + return isJobNameSuit && isJobTypeSuit && isJobDescSuit + } } async function setFilterCondition (selectedFilters) { @@ -938,7 +955,7 @@ async function toRecommendPage (hooks) { notSuitReasonIdToStrategyMap.workExp = expectWorkExpNotMatchStrategy } if ( - !testIfJobTitleOrDescriptionSuit(targetJobData.jobInfo) + !testIfJobTitleOrDescriptionSuit(targetJobData.jobInfo, jobDetailRegExpMatchLogic) ) { notSuitReasonIdToStrategyMap.jobDetail = jobNotMatchStrategy }