perf: 同步ID, 页码会减少

main
Lei OT 8 months ago
parent f974f5c39b
commit 209ff98f36

@ -42,7 +42,7 @@ const Aids = () => {
* 每天启动同步; * 每天启动同步;
*/ */
const AidsState = () => { const AidsState = () => {
const dailyJob = scheduleJob('0 0 0 * * *', async function () { const dailyJob = scheduleJob('0 0 0 * * *', async function () { // debug: 1
// const dailyJob = scheduleJob('0 20 9 * * *', async function () { // const dailyJob = scheduleJob('0 20 9 * * *', async function () {
const jobAS = scheduleJob('*/2 * * * * *', async function () { const jobAS = scheduleJob('*/2 * * * * *', async function () {
console.log('--------------------syncing heytrip, get available accommodation ids.--------------------'); console.log('--------------------syncing heytrip, get available accommodation ids.--------------------');

@ -180,16 +180,18 @@ class Heytrip {
const stateOff = await HeytripIds.findAll({ const stateOff = await HeytripIds.findAll({
raw: true, logging: false, raw: true, logging: false,
where: { where: {
update_flag: 99, // update_flag: 99,
page_index: { [Op.lt]: 0 }, // page_index: { [Op.lt]: 0 },
last_modify_time: { [Op.gt]: today }, // last_modify_time: { [Op.gt]: today },
last_modify_time: { [Op.lt]: today },
}, },
attributes: ['hotel_id'], attributes: ['hotel_id'],
}); });
const stateOffIds = stateOff.map((item) => item.hotel_id); const stateOffIds = stateOff.map((item) => item.hotel_id);
if (!isEmpty(stateOffIds)) { if (!isEmpty(stateOffIds)) {
await HeytripIds.update({ update_flag: 99, priority: 99 }, { where: { hotel_id: stateOffIds }, logging: false, }); // await HeytripIds.update({ update_flag: 99, priority: 99 }, { where: { hotel_id: stateOffIds }, logging: false, });
console.log('updated stateOff', stateOffIds.length); // console.log('updated stateOff', stateOffIds.length);
await HeytripIds.update({ update_flag: 99, priority: 99, page_index: Sequelize.literal('-page_index') }, { where: { last_modify_time: { [Op.lt]: today }, }, logging: false, });
} }
return { return {
nextPage: false, nextPage: false,
@ -221,7 +223,7 @@ class Heytrip {
// 页码滚动 // 页码滚动
const oldToNext = savedPageIds.filter((item) => !validIds.includes((item.hotel_id))).map((item) => item.hotel_id); const oldToNext = savedPageIds.filter((item) => !validIds.includes((item.hotel_id))).map((item) => item.hotel_id);
if (!isEmpty(oldToNext)) { if (!isEmpty(oldToNext)) {
await HeytripIds.update({ page_index: -Number(pageIndex), 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 { return {

Loading…
Cancel
Save