From 7f474378aa13446909107ef3ffe88d1832d6dc4c Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 1 Nov 2024 13:50:25 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=90=8C=E6=AD=A5ID:=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/jobs/syncHeytripJobs.js | 14 +++++++++----- server/services/heytripService.js | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/jobs/syncHeytripJobs.js b/server/jobs/syncHeytripJobs.js index cdf5cd5..2ed2652 100644 --- a/server/jobs/syncHeytripJobs.js +++ b/server/jobs/syncHeytripJobs.js @@ -48,11 +48,15 @@ const AidsState = () => { console.log('--------------------syncing heytrip, get available accommodation ids.--------------------'); const isRunning = jobAS.pendingInvocations[0]?.job?.running == 1; if (!isRunning) { - const res = await heytripService.syncAidState(); - // jobAS.cancel(); // debug: 0 - if (res.nextPage !== true) { - console.log('job completed! canceled job[AidsState]!'); - jobAS.cancel(); + try { + const res = await heytripService.syncAidState(); + // jobAS.cancel(); // debug: 0 + if (res.nextPage !== true) { + console.log('job completed! canceled job[AidsState]!'); + jobAS.cancel(); + } + } catch (error) { + } } else { console.log('pre job running! cancelNext[AidsState]'); diff --git a/server/services/heytripService.js b/server/services/heytripService.js index 2fa4544..1b07c5e 100644 --- a/server/services/heytripService.js +++ b/server/services/heytripService.js @@ -212,7 +212,7 @@ class Heytrip { // 已存在ID: 更新: 状态, 页码, 时间 const stateNormal = savedIds.filter((item) => validIds.includes((item.hotel_id))).map((item) => item.hotel_id); if (!isEmpty(stateNormal)) { - await HeytripIds.update({ update_flag: 0, priority: 0, page_index: pageIndex, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: stateNormal } ,logging: false, }); + await HeytripIds.update({ update_flag: 0, priority: Sequelize.literal('priority+5'), page_index: pageIndex, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: stateNormal } ,logging: false, }); } // 新增ID const newIds = validIds.filter((id) => !savedIds.map((item) => item.hotel_id).includes(id)); @@ -264,7 +264,7 @@ class Heytrip { WHERE h.hi2_sn IS NULL AND update_flag != 99 -- AND update_flag = 0 - ORDER BY info_exists,priority LIMIT 10` + ORDER BY priority LIMIT 10` , { logging: false } ); const res = await this.syncInitHotelLgcDetailsAction(rows, LGC_MAPPED[lgc]);