perf: 同步: 更新优先级

main
Lei OT 8 months ago
parent e34ae9790c
commit 2b028db8d9

@ -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: Sequelize.literal('priority+5'), page_index: pageIndex, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: stateNormal } ,logging: false, });
await HeytripIds.update({ update_flag: 0, priority: 10, 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));
@ -399,13 +399,13 @@ class Heytrip {
const offInfo = allIds.filter((iitem) => !resIds.includes(`${iitem}`));
if (!isEmpty(offInfo)) {
const flag = Number(lgcObj.lgc) === 1 ? 2 : 99; // 等待获取中文数据
const priority = Number(lgcObj.lgc) === 1 ? 10 : 99;
const priority = Number(lgcObj.lgc) === 1 ? 5 : 99;
await HeytripIds.update({ update_flag: flag, priority, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: offInfo }, ...sequelizeOptions });
}
const updateInfo = insertData.info.filter((iitem) => existsIds.includes(`${iitem.hotel_id}`));
if (!isEmpty(updateInfo)) {
await HeytripIds.update({ update_flag: 0, priority: 0, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: updateInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
await HeytripIds.update({ update_flag: 0, priority: 5, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: updateInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
for await (const updateRow of updateInfo) {
// 有中英文的, 把名称合并, eg.上海意家人酒店Yijiaren Hotel
const _BaseName = _BaseInfoExistsMapped[`${updateRow.hotel_id}`].hotel_name;
@ -439,8 +439,8 @@ class Heytrip {
if (!isEmpty(insertData.reviews_summaries)) await ReviewsSummaries.bulkCreate(insertData.reviews_summaries, sequelizeOptions);
if (!isEmpty(insertData.locations)) await Locations.bulkCreate(insertData.locations, sequelizeOptions);
if (!isEmpty(newInfo)) await HeytripIds.update({ update_flag: 0, priority: 0, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: newInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
if (!isEmpty(updateInfo)) await HeytripIds.update({ update_flag: 0, priority: 0, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: updateInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
if (!isEmpty(newInfo)) await HeytripIds.update({ update_flag: 0, priority: 10, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: newInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
if (!isEmpty(updateInfo)) await HeytripIds.update({ update_flag: 0, priority: 10, last_modify_time: Sequelize.fn('NOW') }, { where: { hotel_id: updateInfo.map((x) => x.hotel_id) }, ...sequelizeOptions });
return Info;
});

Loading…
Cancel
Save