Skip to content

Commit

Permalink
record previous list count and diff ids
Browse files Browse the repository at this point in the history
  • Loading branch information
linxin committed Oct 25, 2024
1 parent 484392b commit c669f73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/sites/hk_sfc/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ export class HK_SFC {
);
const previous_total_counts = await getPreviousListCount();

// 每次都记录当前请求到的数据情况
const { diff_list: _diff_ids, not_exist_ids } = await getDiffList(
this.data_list
);

console.log(
"🚀 ~ HK_SFC ~ check_list ~ previous_total_counts:",
previous_total_counts,
"「not_exist_ids」:",
not_exist_ids
);

// // 每次都记录当前请求到的数据情况
await this.insert_meta(this.data_list);
if (previous_total_counts !== this.data_list.length || force) {
if (_diff_ids.length > 0 || force) {
// 前后两次数量不一致就记录
const diff_list = force
? this.data_list
: await getDiffList(this.data_list);
const diff_list = force ? this.data_list : _diff_ids;

if (diff_list.length > 0) {
await this.insert_history(diff_list);
Expand Down
7 changes: 6 additions & 1 deletion src/sites/hk_sfc/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ export const getDiffList = async (new_list: any[]) => {
(item: any) => !previous_list_ids.includes(item.ceref)
);

return diff_list;
const diff_ids = diff_list.map((item: any) => item.ceref);
const not_exist_ids = previous_list_ids.filter(
(id: string) => !diff_ids.includes(id)
);

return { diff_list, not_exist_ids };
};

export const parse_detail_info = async (data_list: any[]) => {
Expand Down

0 comments on commit c669f73

Please sign in to comment.