mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-06-05 07:30:29 +08:00
add filter logic of job salary in script
This commit is contained in:
@@ -18,7 +18,7 @@ import { default as rawIndustryFilterExemption } from './internal-config/job-fil
|
||||
import { ChatStartupFrom } from '@geekgeekrun/sqlite-plugin/dist/entity/ChatStartupLog'
|
||||
import { MarkAsNotSuitReason, MarkAsNotSuitOp, StrategyScopeOptionWhenMarkJobNotMatch, SalaryCalculateWay } from '@geekgeekrun/sqlite-plugin/dist/enums'
|
||||
import { activeDescList } from './constant.mjs'
|
||||
|
||||
import { parseSalary } from "@geekgeekrun/sqlite-plugin/dist/utils/parser"
|
||||
const jobFilterConditionsMapByCode = {}
|
||||
Object.values(jobFilterConditions).forEach(arr => {
|
||||
arr.forEach(option => {
|
||||
@@ -90,7 +90,7 @@ const strategyScopeOptionWhenMarkJobCityNotMatch = readConfigFile('boss.json').s
|
||||
const expectSalaryLow = parseFloat(readConfigFile('boss.json').expectSalaryLow) || null
|
||||
const expectSalaryHigh = parseFloat(readConfigFile('boss.json').expectSalaryHigh) || null
|
||||
const expectSalaryCalculateWay = readConfigFile('boss.json').expectSalaryCalculateWay ?? SalaryCalculateWay.MONTH_SALARY
|
||||
const expectSalaryNotMatchStrategy = readConfigFile('boss.json').expectSalaryCalculateWay ?? MarkAsNotSuitOp.NO_OP
|
||||
const expectSalaryNotMatchStrategy = readConfigFile('boss.json').expectSalaryNotMatchStrategy ?? MarkAsNotSuitOp.NO_OP
|
||||
const isSalaryFilterEnabled = expectSalaryLow || expectSalaryHigh
|
||||
const strategyScopeOptionWhenMarkSalaryNotMatch = readConfigFile('boss.json').strategyScopeOptionWhenMarkSalaryNotMatch ?? StrategyScopeOptionWhenMarkJobNotMatch.ONLY_COMPANY_MATCHED_JOB
|
||||
|
||||
@@ -203,7 +203,8 @@ async function markJobAsNotSuitInRecommendPage (reasonCode) {
|
||||
break
|
||||
}
|
||||
case MarkAsNotSuitReason.JOB_WORK_EXP_NOT_SUIT:
|
||||
case MarkAsNotSuitReason.JOB_CITY_NOT_SUIT: {
|
||||
case MarkAsNotSuitReason.JOB_CITY_NOT_SUIT:
|
||||
case MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT: {
|
||||
const opProxy = (await chooseReasonDialogProxy.$(`.zp-type-item[title$="城市"]`))
|
||||
?? (await chooseReasonDialogProxy.$(`.zp-type-item[title="同城距离远"]`))
|
||||
?? (await chooseReasonDialogProxy.$(`.zp-type-item[title="公司不感兴趣"]`))
|
||||
@@ -548,10 +549,29 @@ async function toRecommendPage (hooks) {
|
||||
// due to city can get from list immediately
|
||||
// so just set those job which city is not suit to blockJobNotSuit
|
||||
// to skip view detail
|
||||
|
||||
// skip invalid salaryData (兼职、日结、实习 etc)
|
||||
jobListData.forEach(it => {
|
||||
const salaryData = parseSalary(it.salaryDesc)
|
||||
if (!salaryData.high || !salaryData.low) {
|
||||
blockJobNotSuit.add(it.encryptJobId)
|
||||
}
|
||||
})
|
||||
if (
|
||||
expectCityNotMatchStrategy === MarkAsNotSuitOp.NO_OP &&
|
||||
Array.isArray(expectCityList) &&
|
||||
expectCityList.length
|
||||
(
|
||||
expectCityNotMatchStrategy === MarkAsNotSuitOp.NO_OP &&
|
||||
Array.isArray(expectCityList) &&
|
||||
expectCityList.length
|
||||
) ||
|
||||
(
|
||||
expectWorkExpNotMatchStrategy === MarkAsNotSuitOp.NO_OP &&
|
||||
Array.isArray(expectWorkExpList) &&
|
||||
expectWorkExpList.length
|
||||
) ||
|
||||
(
|
||||
strategyScopeOptionWhenMarkSalaryNotMatch === MarkAsNotSuitOp.NO_OP &&
|
||||
isSalaryFilterEnabled
|
||||
)
|
||||
) {
|
||||
console.log(`add job city not suit into blockJobNotSuit set`)
|
||||
for (const it of jobListData) {
|
||||
@@ -566,6 +586,26 @@ async function toRecommendPage (hooks) {
|
||||
let hasReachLastPage = false
|
||||
let targetJobIndex = -1
|
||||
let targetJobData, selectedJobData // they show be same; one is from list, another is from detail
|
||||
function checkIfSalarySuit(salaryDesc) {
|
||||
const salaryData = parseSalary(salaryDesc)
|
||||
if (expectSalaryCalculateWay === SalaryCalculateWay.MONTH_SALARY) {
|
||||
if (expectSalaryHigh && salaryData.high > expectSalaryHigh) {
|
||||
return false
|
||||
}
|
||||
if (expectSalaryLow && salaryData.low < expectSalaryLow) {
|
||||
return false
|
||||
}
|
||||
} else if (expectSalaryCalculateWay === SalaryCalculateWay.ANNUAL_PACKAGE) {
|
||||
const salaryDataMonth = salaryData.month || 12
|
||||
if (expectSalaryHigh && (salaryData.high * salaryDataMonth) / 10 > expectSalaryHigh) {
|
||||
return false
|
||||
}
|
||||
if (expectSalaryLow && (salaryData.low * salaryDataMonth) / 10 < expectSalaryLow) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
function getTempTargetJobIndexToCheckDetail () {
|
||||
return jobListData.findIndex(it => {
|
||||
return !blockBossNotNewChat.has(it.encryptBossId) &&
|
||||
@@ -601,6 +641,16 @@ async function toRecommendPage (hooks) {
|
||||
].includes(expectWorkExpNotMatchStrategy) &&
|
||||
strategyScopeOptionWhenMarkJobWorkExpNotMatch === StrategyScopeOptionWhenMarkJobNotMatch.ALL_JOB
|
||||
) ? !expectWorkExpList.includes(it.jobExperience) : false
|
||||
) || (
|
||||
// enter job detail to mark as not suit for salary filter
|
||||
(
|
||||
isSalaryFilterEnabled &&
|
||||
[
|
||||
MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS,
|
||||
MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL
|
||||
].includes(expectSalaryNotMatchStrategy) &&
|
||||
strategyScopeOptionWhenMarkSalaryNotMatch === StrategyScopeOptionWhenMarkJobNotMatch.ALL_JOB
|
||||
) ? !checkIfSalarySuit(it.salaryDesc) : false
|
||||
)
|
||||
)
|
||||
})
|
||||
@@ -824,6 +874,43 @@ async function toRecommendPage (hooks) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
},
|
||||
async salary() {
|
||||
blockJobNotSuit.add(targetJobData.jobInfo.encryptId)
|
||||
if (expectSalaryNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
targetJobData,
|
||||
{
|
||||
markFrom: ChatStartupFrom.AutoFromRecommendList,
|
||||
markReason: MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT,
|
||||
extInfo: {
|
||||
salaryDesc: selectedJobData.salaryDesc,
|
||||
chosenReasonInUi
|
||||
},
|
||||
markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
else if (expectSalaryNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL) {
|
||||
try {
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
targetJobData,
|
||||
{
|
||||
markFrom: ChatStartupFrom.AutoFromRecommendList,
|
||||
markReason: MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT,
|
||||
extInfo: {
|
||||
salaryDesc: selectedJobData.salaryDesc,
|
||||
},
|
||||
markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -855,7 +942,13 @@ async function toRecommendPage (hooks) {
|
||||
) {
|
||||
notSuitReasonIdToStrategyMap.jobDetail = jobNotMatchStrategy
|
||||
}
|
||||
if (
|
||||
!checkIfSalarySuit(selectedJobData.salaryDesc)
|
||||
) {
|
||||
notSuitReasonIdToStrategyMap.salary = expectSalaryNotMatchStrategy
|
||||
}
|
||||
// #endregion
|
||||
console.log('not suit reason and related strategy: ', notSuitReasonIdToStrategyMap)
|
||||
|
||||
// #region execute mark logic
|
||||
// 1. find the one mark on Boss
|
||||
|
||||
@@ -5,6 +5,7 @@ export enum MarkAsNotSuitReason {
|
||||
JOB_NOT_SUIT = 3,
|
||||
JOB_CITY_NOT_SUIT = 4,
|
||||
JOB_WORK_EXP_NOT_SUIT = 5,
|
||||
JOB_SALARY_NOT_SUIT = 6,
|
||||
}
|
||||
|
||||
export enum MarkAsNotSuitOp {
|
||||
@@ -20,5 +21,5 @@ export enum StrategyScopeOptionWhenMarkJobNotMatch {
|
||||
|
||||
export enum SalaryCalculateWay {
|
||||
MONTH_SALARY = 1,
|
||||
ANNUAL_PACKAGE = 2
|
||||
ANNUAL_PACKAGE = 2,
|
||||
}
|
||||
@@ -46,6 +46,10 @@
|
||||
<strong>{{ markReasonTopicMap[row.markReason] }}</strong>
|
||||
<pre class="m-0 of-auto">{{ formatMarkReason(row) }}</pre>
|
||||
</template>
|
||||
<template v-if="row.markReason === MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT">
|
||||
<strong>{{ markReasonTopicMap[row.markReason] }}</strong>
|
||||
<pre class="m-0 of-auto">{{ formatMarkReason(row) }}</pre>
|
||||
</template>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="experienceName" label="工作经验" />
|
||||
@@ -214,7 +218,8 @@ const markReasonTopicMap = {
|
||||
[MarkAsNotSuitReason.USER_MANUAL_OPERATION_WITH_UNKNOWN_REASON]: '手动标记不合适',
|
||||
[MarkAsNotSuitReason.JOB_NOT_SUIT]: '职位不合适',
|
||||
[MarkAsNotSuitReason.JOB_CITY_NOT_SUIT]: '工作地不合适',
|
||||
[MarkAsNotSuitReason.JOB_WORK_EXP_NOT_SUIT]: '工作经验不合适'
|
||||
[MarkAsNotSuitReason.JOB_WORK_EXP_NOT_SUIT]: '工作经验不合适',
|
||||
[MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT]: '薪资不合适'
|
||||
}
|
||||
|
||||
function formatMarkReason(row: VMarkAsNotSuitLog) {
|
||||
@@ -259,6 +264,21 @@ function formatMarkReason(row: VMarkAsNotSuitLog) {
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
}
|
||||
case MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT: {
|
||||
const extInfo = (() => {
|
||||
try {
|
||||
return JSON.parse(row.extInfo)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})()
|
||||
return [
|
||||
extInfo?.salaryDesc && `薪资:${extInfo.salaryDesc}`,
|
||||
extInfo?.chosenReasonInUi?.text && `Boss选项内容:${extInfo.chosenReasonInUi.text}`
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
}
|
||||
default: {
|
||||
return ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user