From e867acb39d75257a40dde8baac6f914ce569ba97 Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sun, 13 Jul 2025 14:27:43 +0800 Subject: [PATCH] collect jobSource when auto startup chat running --- .../geek-auto-start-chat-with-boss/index.mjs | 40 +++++++++++++------ packages/sqlite-plugin/src/handlers.ts | 10 +++-- packages/sqlite-plugin/src/index.ts | 10 +++-- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/packages/geek-auto-start-chat-with-boss/index.mjs b/packages/geek-auto-start-chat-with-boss/index.mjs index a0aa7f0..ad6341a 100644 --- a/packages/geek-auto-start-chat-with-boss/index.mjs +++ b/packages/geek-auto-start-chat-with-boss/index.mjs @@ -20,7 +20,7 @@ import { 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, JobDetailRegExpMatchLogic } from '@geekgeekrun/sqlite-plugin/dist/enums' +import { MarkAsNotSuitReason, MarkAsNotSuitOp, StrategyScopeOptionWhenMarkJobNotMatch, SalaryCalculateWay, JobDetailRegExpMatchLogic, JobSource } from '@geekgeekrun/sqlite-plugin/dist/enums' import { activeDescList } from './constant.mjs' import { parseSalary } from "@geekgeekrun/sqlite-plugin/dist/utils/parser" const jobFilterConditionsMapByCode = {} @@ -938,7 +938,8 @@ async function toRecommendPage (hooks) { markFrom: ChatStartupFrom.AutoFromRecommendList, markReason: MarkAsNotSuitReason.BOSS_INACTIVE, extInfo: null, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -956,7 +957,8 @@ async function toRecommendPage (hooks) { bossActiveTimeDesc: targetJobData.bossInfo.activeTimeDesc, chosenReasonInUi }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -973,7 +975,8 @@ async function toRecommendPage (hooks) { markFrom: ChatStartupFrom.AutoFromRecommendList, markReason: MarkAsNotSuitReason.JOB_CITY_NOT_SUIT, extInfo: null, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -990,7 +993,8 @@ async function toRecommendPage (hooks) { extInfo: { chosenReasonInUi }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1007,7 +1011,8 @@ async function toRecommendPage (hooks) { markFrom: ChatStartupFrom.AutoFromRecommendList, markReason: MarkAsNotSuitReason.JOB_WORK_EXP_NOT_SUIT, extInfo: null, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1024,7 +1029,8 @@ async function toRecommendPage (hooks) { extInfo: { chosenReasonInUi }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1041,7 +1047,8 @@ async function toRecommendPage (hooks) { markFrom: ChatStartupFrom.AutoFromRecommendList, markReason: MarkAsNotSuitReason.JOB_NOT_SUIT, extInfo: null, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1059,7 +1066,8 @@ async function toRecommendPage (hooks) { bossActiveTimeDesc: targetJobData.bossInfo.activeTimeDesc, chosenReasonInUi }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1078,7 +1086,8 @@ async function toRecommendPage (hooks) { extInfo: { salaryDesc: selectedJobData.salaryDesc, }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_LOCAL, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1096,7 +1105,8 @@ async function toRecommendPage (hooks) { salaryDesc: selectedJobData.salaryDesc, chosenReasonInUi }, - markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS + markOp: MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] } ) } catch { @@ -1226,7 +1236,13 @@ async function toRecommendPage (hooks) { throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR') } } else { - await hooks.newChatStartup?.promise(targetJobData, { chatStartupFrom: ChatStartupFrom.AutoFromRecommendList }) + await hooks.newChatStartup?.promise( + targetJobData, + { + chatStartupFrom: ChatStartupFrom.AutoFromRecommendList, + jobSource: JobSource[computedSourceList[currentSourceIndex]?.type] + } + ) blockBossNotNewChat.add(targetJobData.jobInfo.encryptUserId) await storeStorage(page).catch(() => void 0) diff --git a/packages/sqlite-plugin/src/handlers.ts b/packages/sqlite-plugin/src/handlers.ts index 38ebf0d..61bc121 100644 --- a/packages/sqlite-plugin/src/handlers.ts +++ b/packages/sqlite-plugin/src/handlers.ts @@ -245,7 +245,7 @@ export async function saveChatStartupRecord( ds: DataSource, _jobInfo, { encryptUserId }, - { autoStartupChatRecordId = undefined, chatStartupFrom = undefined } = {} + { autoStartupChatRecordId = undefined, chatStartupFrom = undefined, jobSource = undefined } = {} ) { const { jobInfo } = _jobInfo; @@ -256,7 +256,8 @@ export async function saveChatStartupRecord( encryptCurrentUserId: encryptUserId, encryptJobId: jobInfo.encryptId, autoStartupChatRecordId, - chatStartupFrom + chatStartupFrom, + jobSource, } Object.assign(chatStartupLog, chatStartupLogPayload) @@ -270,7 +271,7 @@ export async function saveMarkAsNotSuitRecord( ds: DataSource, _jobInfo, { encryptUserId }, - { autoStartupChatRecordId = undefined, markFrom = undefined, extInfo = undefined, markReason = undefined, markOp = undefined } = {} + { autoStartupChatRecordId = undefined, markFrom = undefined, extInfo = undefined, markReason = undefined, markOp = undefined, jobSource = undefined } = {} ) { const { jobInfo } = _jobInfo; @@ -284,7 +285,8 @@ export async function saveMarkAsNotSuitRecord( markFrom, markReason, extInfo: extInfo ? JSON.stringify(extInfo) : undefined, - markOp + markOp, + jobSource, } Object.assign(markAsNotSuitLog, markAsNotSuitLogPayload) diff --git a/packages/sqlite-plugin/src/index.ts b/packages/sqlite-plugin/src/index.ts index 43f058f..e4f6959 100644 --- a/packages/sqlite-plugin/src/index.ts +++ b/packages/sqlite-plugin/src/index.ts @@ -188,22 +188,24 @@ export default class SqlitePlugin { await saveJobInfoFromRecommendPage(ds, _jobInfo); }); - hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo, { chatStartupFrom = ChatStartupFrom.AutoFromRecommendList } = {}) => { + hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo, { chatStartupFrom = ChatStartupFrom.AutoFromRecommendList, jobSource = undefined } = {}) => { const ds = await this.initPromise; return await saveChatStartupRecord(ds, _jobInfo, this.userInfo, { autoStartupChatRecordId: this.runRecordId, - chatStartupFrom + chatStartupFrom, + jobSource }); }); - hooks.jobMarkedAsNotSuit.tapPromise("SqlitePlugin", async (_jobInfo, { markFrom = ChatStartupFrom.AutoFromRecommendList, markReason = undefined, extInfo = undefined, markOp = undefined } = {}) => { + hooks.jobMarkedAsNotSuit.tapPromise("SqlitePlugin", async (_jobInfo, { markFrom = ChatStartupFrom.AutoFromRecommendList, markReason = undefined, extInfo = undefined, markOp = undefined, jobSource = undefined } = {}) => { const ds = await this.initPromise; return await saveMarkAsNotSuitRecord(ds, _jobInfo, this.userInfo, { autoStartupChatRecordId: this.runRecordId, markFrom, markReason, extInfo, - markOp + markOp, + jobSource }); }); }