mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-24 17:50:13 +08:00
save boss active status in db
This commit is contained in:
@@ -168,7 +168,6 @@ async function toRecommendPage (hooks) {
|
||||
) : jobListData.findIndex(
|
||||
it => !blockBossNotNewChat.has(it.encryptBossId)
|
||||
)
|
||||
debugger
|
||||
|
||||
let hasReachLastPage = false
|
||||
|
||||
@@ -283,6 +282,8 @@ async function toRecommendPage (hooks) {
|
||||
await sleepWithRandomDelay(2000)
|
||||
}
|
||||
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()')
|
||||
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);
|
||||
const ds = await this.initPromise;
|
||||
|
||||
@@ -130,6 +130,31 @@ export default class SqlitePlugin {
|
||||
await jobInfoRepository.save(job);
|
||||
//#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
|
||||
const chatStartupLog = new ChatStartupLog()
|
||||
const chatStartupLogPayload: Partial<ChatStartupLog> = {
|
||||
@@ -139,6 +164,7 @@ export default class SqlitePlugin {
|
||||
}
|
||||
Object.assign(chatStartupLog, chatStartupLogPayload)
|
||||
|
||||
const ds = await this.initPromise;
|
||||
const chatStartupLogRepository = ds.getRepository(ChatStartupLog);
|
||||
await chatStartupLogRepository.save(chatStartupLog);
|
||||
//#endregion
|
||||
|
||||
@@ -83,6 +83,7 @@ const runAutoChat = async () => {
|
||||
pageLoaded: new SyncHook(),
|
||||
cookieWillSet: new SyncHook(['cookies']),
|
||||
userInfoResponse: new AsyncSeriesHook(['userInfo']),
|
||||
jobDetailIsGetFromRecommendList: new AsyncSeriesHook(['userInfo']),
|
||||
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||
newChatStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||
noPositionFoundForCurrentJob: new SyncHook(),
|
||||
|
||||
Reference in New Issue
Block a user