Skip to content

Commit

Permalink
Do not crawl data we already got in 7 days.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Oct 29, 2023
1 parent 72fa5dd commit 27e335e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/task/imdbTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ async function getNewImdbInfos(): Promise<Movie[]> {
);
}

function filterNeedCrawlMovie({ englishTitle, releaseDate }: Movie) {
function filterNeedCrawlMovie({ englishTitle, releaseDate, imdbID, imdbRating, imdbLastCrawlTime }: Movie) {
const now = moment();
const isRecentMovie = now.diff(moment(releaseDate), 'months') <= 6;
const shouldCrawl = englishTitle && isRecentMovie;
const dataJustCrawled = imdbID && imdbRating && now.diff(moment(imdbLastCrawlTime), 'days') <= 7;
const shouldCrawl = !dataJustCrawled && englishTitle && isRecentMovie;
return shouldCrawl;
}

Expand Down

0 comments on commit 27e335e

Please sign in to comment.