fix: 同步酒店ID, 按页码

main
Lei OT 8 months ago
parent fb33f24820
commit f974f5c39b

@ -65,11 +65,11 @@ const AidsState = () => {
/**
* 获取新增的酒店详情
* ID同步结束后启动, ID每10W 条大约需要半小时
* 每天03:05:00启动
* * 每天
*/
const newHotelDetails = () => {
// return false;
const dailyJob1 = scheduleJob('0 5 3 * * *', async function () {
const dailyJob1 = scheduleJob('0 5 8 * * *', async function () {
// const dailyJob1 = scheduleJob('0 5 12 * * *', async function () {
const job1 = scheduleJob('*/5 * * * * *', async function () {
console.log('-------------------------syncing heytrip[newHotelDetails], get accommodation details.-------------------------');

@ -160,14 +160,15 @@ class Heytrip {
const today = new Date();
today.setHours(0, 0, 0, 0); // set the time to 00:00:00.000
let lastPageIndex; let pageIndex;
lastPageIndex = await this.getFirstPageIndex({ last_modify_time: { [Op.lt]: today }, page_index: { [Op.lt]: 9999 } });
pageIndex = lastPageIndex;
let lastPageIndex;
let pageIndex;
// lastPageIndex = await this.getFirstPageIndex({ last_modify_time: { [Op.lt]: today }, page_index: { [Op.lt]: 9999 } });
// pageIndex = lastPageIndex;
if (isEmpty(lastPageIndex)) {
lastPageIndex = await this.getLastPageIndex({ last_modify_time: { [Op.gt]: today }, page_index: { [Op.lt]: 9999 } });
lastPageIndex = await this.getLastPageIndex({ last_modify_time: { [Op.gt]: today }, page_index: { [Op.gt]: 0 } });
// console.log('syncAidState', 'lastPageIndex', lastPageIndex);
pageIndex = lastPageIndex + 1;
pageIndex = (lastPageIndex || 0) + 1;
}
console.log('syncAidState', lastPageIndex, pageIndex);
@ -180,7 +181,7 @@ class Heytrip {
raw: true, logging: false,
where: {
update_flag: 99,
page_index: { [Op.gt]: 9999 },
page_index: { [Op.lt]: 0 },
last_modify_time: { [Op.gt]: today },
},
attributes: ['hotel_id'],
@ -220,7 +221,7 @@ class Heytrip {
// 页码滚动
const oldToNext = savedPageIds.filter((item) => !validIds.includes((item.hotel_id))).map((item) => item.hotel_id);
if (!isEmpty(oldToNext)) {
await HeytripIds.update({ page_index: Number(pageIndex)+9999, update_flag: 99 }, { where: { hotel_id: oldToNext },logging: false, });
await HeytripIds.update({ page_index: -Number(pageIndex), update_flag: 99 }, { where: { hotel_id: oldToNext },logging: false, });
}
return {

Loading…
Cancel
Save