Skip to content

Commit

Permalink
Add logs to trace the crawlMovieSchdule
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Aug 4, 2023
1 parent 456a153 commit 28733fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/crawler/movieSchduleCrawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export async function crawlMovieSchdule(scheduleUrl, date) {
});
}
catch (error) {
console.error('crawlMovieSchdule fail!');
console.error(error);
}
console.log(`crawlMovieSchdule(${scheduleUrl}, ${date}), schedules.length: ${schedules.length}`)
return schedules;
}
2 changes: 2 additions & 0 deletions src/task/atmoviesTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export async function updateMoviesSchedules() {
.find({}, { projection: { scheduleUrl: 1, _id: 0 } })
.toArray();
const scheduleCrawlDate = await getScheduleCrawlDate();
console.log('scheduleCrawlDate', scheduleCrawlDate);
let schedulesPromise = scheduleUrls.map(({ scheduleUrl }) =>
crawlMovieSchdule(scheduleUrl, scheduleCrawlDate)
);
const schedules = await Promise.all(schedulesPromise);
const allSchedules: Schedule[] = [].concat(...schedules);
console.log('allSchedules.length', allSchedules.length);
redisClient.setex(scheduleCrawlDate, 86400 * 2, JSON.stringify(allSchedules));
return allSchedules;
}
Expand Down

0 comments on commit 28733fa

Please sign in to comment.