Skip to content

Commit

Permalink
Rename to represent outcome rather than implementation #3234
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcmoulton committed May 10, 2024
1 parent 179a02d commit d444eb4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Expand Up @@ -3,7 +3,7 @@ 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 { daysAgo } from '../time';
import { ingestionWindowStartDate } from '../time';
import { constructPublishedEvaluation } from '../types/published-evaluation';
import { DiscoverPublishedEvaluations } from '../update-all';

Expand Down Expand Up @@ -58,7 +58,7 @@ const fetchPaginatedData = (baseUrl: string, offset: number): TE.TaskEither<stri
);

const identifyCandidates = (doiPrefix: string, reviewDoiPrefix: string) => {
const startDate = daysAgo(60).toISOString().split('T')[0];
const startDate = ingestionWindowStartDate(60).toISOString().split('T')[0];
const today = new Date().toISOString().split('T')[0];
const baseUrl = `https://api.biorxiv.org/publisher/${doiPrefix}/${startDate}/${today}`;
return pipe(
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { FetchData } from '../fetch-data';
import { tagToEvaluationTypeMap } from '../tag-to-evaluation-type-map';
import * as Hyp from '../third-parties/hypothesis';
import { convertHypothesisAnnotationToEvaluation } from '../third-parties/hypothesis/convert-hypothesis-annotation-to-evaluation';
import { daysAgo } from '../time';
import { ingestionWindowStartDate } from '../time';
import { DiscoverPublishedEvaluations } from '../update-all';

type Ports = {
Expand All @@ -15,7 +15,7 @@ type Ports = {
const calculateEarliestPublicationDateToConsider = (earliestPublicationDateToConsider: Date | undefined): Date => (
earliestPublicationDateToConsider instanceof Date
? earliestPublicationDateToConsider
: daysAgo(5)
: ingestionWindowStartDate(5)
);

export const discoverEvaluationsFromHypothesisGroup = (
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { FetchData } from '../fetch-data';
import { tagToEvaluationTypeMap } from '../tag-to-evaluation-type-map';
import * as Hyp from '../third-parties/hypothesis';
import { convertHypothesisAnnotationToEvaluation } from '../third-parties/hypothesis/convert-hypothesis-annotation-to-evaluation';
import { daysAgo } from '../time';
import { ingestionWindowStartDate } from '../time';
import { DiscoverPublishedEvaluations } from '../update-all';

type Ports = {
Expand All @@ -17,7 +17,7 @@ export const discoverEvaluationsFromHypothesisUser = (
daysToLookBackForAcceptablePerformance = 5,
): DiscoverPublishedEvaluations => (ports: Ports) => pipe(
publisherUserId,
Hyp.fetchEvaluationsByUserSince(daysAgo(daysToLookBackForAcceptablePerformance), ports.fetchData),
Hyp.fetchEvaluationsByUserSince(ingestionWindowStartDate(daysToLookBackForAcceptablePerformance), ports.fetchData),
TE.map(RA.map(convertHypothesisAnnotationToEvaluation(tagToEvaluationTypeMap))),
TE.map((parts) => ({
understood: RA.rights(parts),
Expand Down
4 changes: 2 additions & 2 deletions src/ingest/evaluation-discovery/discover-pci-evaluations.ts
Expand Up @@ -6,7 +6,7 @@ import { pipe } from 'fp-ts/function';
import * as S from 'fp-ts/string';
import * as AID from '../../types/article-id';
import { FetchData } from '../fetch-data';
import { daysAgo } from '../time';
import { ingestionWindowStartDate } from '../time';
import { constructPublishedEvaluation } from '../types/published-evaluation';
import { DiscoverPublishedEvaluations } from '../update-all';

Expand All @@ -16,7 +16,7 @@ type Candidate = {
reviewId: string,
};

const since = daysAgo(60);
const since = ingestionWindowStartDate(60);

const identifyCandidates = (feed: string) => {
const parser = new DOMParser({
Expand Down
Expand Up @@ -5,7 +5,7 @@ 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 { daysAgo } from '../time';
import { ingestionWindowStartDate } from '../time';
import { constructPublishedEvaluation } from '../types/published-evaluation';
import { DiscoverPublishedEvaluations } from '../update-all';

Expand All @@ -14,7 +14,7 @@ type Ports = {
};

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

const toEvaluationOrSkip = (candidate: CR.CrossrefReview) => pipe(
Expand Down
2 changes: 1 addition & 1 deletion src/ingest/time.ts
@@ -1,4 +1,4 @@
export const daysAgo = (defaultDays: number): Date => {
export const ingestionWindowStartDate = (defaultDays: number): Date => {
let days = parseInt(process.env.INGEST_DAYS ?? '', 10);
if (Number.isNaN(days)) {
days = defaultDays;
Expand Down
Expand Up @@ -2,7 +2,7 @@ import * as E from 'fp-ts/Either';
import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
import { discoverPciEvaluations } from '../../../src/ingest/evaluation-discovery/discover-pci-evaluations';
import { daysAgo } from '../../../src/ingest/time';
import { ingestionWindowStartDate } from '../../../src/ingest/time';
import { constructPublishedEvaluation } from '../../../src/ingest/types/published-evaluation';
import { arbitraryUri } from '../../helpers';
import { shouldNotBeCalled } from '../../should-not-be-called';
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('discover-pci-evaluations', () => {
it('returns 1 evaluation and no skipped items', async () => {
const articleId = arbitraryArticleId().value;
const reviewId = arbitraryArticleId().value;
const date = daysAgo(5);
const date = ingestionWindowStartDate(5);
const pciXmlResponse = `
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<links>
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('discover-pci-evaluations', () => {
<link providerId="PCIArchaeology">
<resource>
<doi>10.24072/pci.archaeo.100011</doi>
<date>${daysAgo(5).toISOString()}</date>
<date>${ingestionWindowStartDate(5).toISOString()}</date>
</resource>
<doi>${articleId}</doi>
</link>
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('discover-pci-evaluations', () => {
<link providerId="PCIArchaeology">
<resource>
<doi>${evaluationId}</doi>
<date>${daysAgo(5).toISOString()}</date>
<date>${ingestionWindowStartDate(5).toISOString()}</date>
</resource>
<doi>${arbitraryArticleId().value}</doi>
</link>
Expand Down

0 comments on commit d444eb4

Please sign in to comment.