Skip to content

Commit

Permalink
Encapsulate hardcoded ingestion window for Rapid Reviews ingestion #3234
Browse files Browse the repository at this point in the history
  • Loading branch information
erkannt committed May 13, 2024
1 parent e9d3835 commit f3e9134
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
import { FetchData } from '../fetch-data';
import * as CR from '../third-parties/crossref';
import { deprecatedIngestionWindowStartDate } from '../time';
import { constructPublishedEvaluation } from '../types/published-evaluation';
import { DiscoverPublishedEvaluations } from '../update-all';

type Ports = {
fetchData: FetchData,
};

const shortIngestionWindowStartDateToAvoidMissingEvaluationsDueToNonPagingFetcher = (
): Date => new Date(Date.now() - 1 * 24 * 60 * 60 * 1000);

const identifyCandidates = (fetchData: FetchData) => (
CR.fetchReviewsIndexedSince(fetchData)('10.1162', deprecatedIngestionWindowStartDate(1))
CR.fetchReviewsIndexedSince(fetchData)('10.1162', shortIngestionWindowStartDateToAvoidMissingEvaluationsDueToNonPagingFetcher())
);

const toEvaluationOrSkip = (candidate: CR.CrossrefReview) => pipe(
Expand Down
8 changes: 0 additions & 8 deletions src/ingest/time.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
export const deprecatedIngestionWindowStartDate = (defaultDays: number): Date => {
let days = parseInt(process.env.INGEST_DAYS ?? '', 10);
if (Number.isNaN(days)) {
days = defaultDays;
}
return new Date(Date.now() - days * 24 * 60 * 60 * 1000);
};

export const ingestionWindowStartDate = (
ingestDays: number,
): Date => new Date(Date.now() - ingestDays * 24 * 60 * 60 * 1000);

0 comments on commit f3e9134

Please sign in to comment.