mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
save boss active status in db
This commit is contained in:
@@ -168,7 +168,6 @@ async function toRecommendPage (hooks) {
|
|||||||
) : jobListData.findIndex(
|
) : jobListData.findIndex(
|
||||||
it => !blockBossNotNewChat.has(it.encryptBossId)
|
it => !blockBossNotNewChat.has(it.encryptBossId)
|
||||||
)
|
)
|
||||||
debugger
|
|
||||||
|
|
||||||
let hasReachLastPage = false
|
let hasReachLastPage = false
|
||||||
|
|
||||||
@@ -283,6 +282,8 @@ async function toRecommendPage (hooks) {
|
|||||||
await sleepWithRandomDelay(2000)
|
await sleepWithRandomDelay(2000)
|
||||||
}
|
}
|
||||||
const jobData = await page.evaluate('document.querySelector(".job-detail-box").__vue__.data')
|
const jobData = await page.evaluate('document.querySelector(".job-detail-box").__vue__.data')
|
||||||
|
// save the job detail info
|
||||||
|
await hooks.jobDetailIsGetFromRecommendList?.promise(jobData)
|
||||||
|
|
||||||
const startChatButtonInnerHTML = await page.evaluate('document.querySelector(".job-detail-box .op-btn.op-btn-chat")?.innerHTML.trim()')
|
const startChatButtonInnerHTML = await page.evaluate('document.querySelector(".job-detail-box .op-btn.op-btn-chat")?.innerHTML.trim()')
|
||||||
if (startChatButtonInnerHTML === '立即沟通') {
|
if (startChatButtonInnerHTML === '立即沟通') {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export default class SqlitePlugin {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo) => {
|
hooks.jobDetailIsGetFromRecommendList.tapPromise("SqlitePlugin", async (_jobInfo) => {
|
||||||
console.log(_jobInfo);
|
console.log(_jobInfo);
|
||||||
const ds = await this.initPromise;
|
const ds = await this.initPromise;
|
||||||
|
|
||||||
@@ -130,6 +130,31 @@ export default class SqlitePlugin {
|
|||||||
await jobInfoRepository.save(job);
|
await jobInfoRepository.save(job);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region save boss active status
|
||||||
|
// look up if the lastActiveStatus of the newest one is equal to the current one.
|
||||||
|
// if equal, just update the updateDate
|
||||||
|
// else insert a new record
|
||||||
|
|
||||||
|
const bossActiveStatusRecord = new BossActiveStatusRecord();
|
||||||
|
bossActiveStatusRecord.encryptBossId = boss.encryptBossId;
|
||||||
|
bossActiveStatusRecord.updateDate = new Date();
|
||||||
|
bossActiveStatusRecord.lastActiveStatus = bossInfo.activeTimeDesc;
|
||||||
|
|
||||||
|
const bossActiveStatusRecordRepository = ds.getRepository(BossActiveStatusRecord);
|
||||||
|
const existNewestRecordByBossId = await bossActiveStatusRecordRepository.findOne(
|
||||||
|
{ where: { encryptBossId: boss.encryptBossId }, order: { updateDate: 'DESC'} }
|
||||||
|
)
|
||||||
|
if (existNewestRecordByBossId && existNewestRecordByBossId.lastActiveStatus === bossInfo.activeTimeDesc) {
|
||||||
|
bossActiveStatusRecord.id = existNewestRecordByBossId.id
|
||||||
|
}
|
||||||
|
await bossActiveStatusRecordRepository.save(bossActiveStatusRecord)
|
||||||
|
//#endregion
|
||||||
|
return
|
||||||
|
});
|
||||||
|
|
||||||
|
hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo) => {
|
||||||
|
const { jobInfo } = _jobInfo;
|
||||||
|
|
||||||
//#region chat-startup-log
|
//#region chat-startup-log
|
||||||
const chatStartupLog = new ChatStartupLog()
|
const chatStartupLog = new ChatStartupLog()
|
||||||
const chatStartupLogPayload: Partial<ChatStartupLog> = {
|
const chatStartupLogPayload: Partial<ChatStartupLog> = {
|
||||||
@@ -139,6 +164,7 @@ export default class SqlitePlugin {
|
|||||||
}
|
}
|
||||||
Object.assign(chatStartupLog, chatStartupLogPayload)
|
Object.assign(chatStartupLog, chatStartupLogPayload)
|
||||||
|
|
||||||
|
const ds = await this.initPromise;
|
||||||
const chatStartupLogRepository = ds.getRepository(ChatStartupLog);
|
const chatStartupLogRepository = ds.getRepository(ChatStartupLog);
|
||||||
await chatStartupLogRepository.save(chatStartupLog);
|
await chatStartupLogRepository.save(chatStartupLog);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ const runAutoChat = async () => {
|
|||||||
pageLoaded: new SyncHook(),
|
pageLoaded: new SyncHook(),
|
||||||
cookieWillSet: new SyncHook(['cookies']),
|
cookieWillSet: new SyncHook(['cookies']),
|
||||||
userInfoResponse: new AsyncSeriesHook(['userInfo']),
|
userInfoResponse: new AsyncSeriesHook(['userInfo']),
|
||||||
|
jobDetailIsGetFromRecommendList: new AsyncSeriesHook(['userInfo']),
|
||||||
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||||
newChatStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
newChatStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||||
noPositionFoundForCurrentJob: new SyncHook(),
|
noPositionFoundForCurrentJob: new SyncHook(),
|
||||||
|
|||||||
Reference in New Issue
Block a user