Skip to content

Commit

Permalink
Match changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Apr 19, 2024
1 parent b0b2072 commit 56da919
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/Program.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Effect, Match, Option, ReadonlyArray, Stream, flow } from 'effect'
import { Array, Effect, Match, Option, Stream, flow } from 'effect'
import * as Decision from './Decision.js'
import * as Doi from './Doi.js'
import * as Orcid from './Orcid.js'
Expand All @@ -10,13 +10,13 @@ import * as Zenodo from './Zenodo.js'
const getPeerReviewsForOrcidId = flow(
(user: Users.User) => Orcid.getPeerReviewsForOrcidId(user.orcidId),
Effect.flatMap(
ReadonlyArray.findFirst(
Array.findFirst(
(group): group is Orcid.PrereviewGroupSchema =>
group['external-ids']['external-id'][0]['external-id-value'] === 'orcid-generated:prereview',
),
),
Effect.map(group =>
ReadonlyArray.map(
Array.map(
group['peer-review-group'],
peerReview =>
({
Expand Down Expand Up @@ -80,12 +80,12 @@ const getPeerReviewsOnZenodoForOrcidId = flow(
}),
),
Effect.map(reviews =>
ReadonlyArray.map(
Array.map(
reviews.hits,
review =>
({
doi: review.doi,
preprintDoi: ReadonlyArray.findFirst(
preprintDoi: Array.findFirst(
review.metadata.related_identifiers,
relatedIdentifier => relatedIdentifier.relation === 'reviews' && relatedIdentifier.scheme === 'doi',
).pipe(
Expand Down Expand Up @@ -119,11 +119,11 @@ const makeDecisions = ({
zenodoReviews: ReadonlyArray<ZenodoReview>
orcidReviews: ReadonlyArray<OrcidReview>
}) =>
ReadonlyArray.union(
ReadonlyArray.filter(
Array.union(
Array.filter(
zenodoReviews,
zenodoReview =>
!ReadonlyArray.contains(
!Array.contains(
orcidReviews.map(review => review.doi),
zenodoReview.doi,
),
Expand All @@ -133,10 +133,10 @@ const makeDecisions = ({
...zenodoReview,
}),
),
ReadonlyArray.filter(
Array.filter(
orcidReviews,
orcidReview =>
!ReadonlyArray.contains(
!Array.contains(
zenodoReviews.map(review => review.doi),
orcidReview.doi,
),
Expand Down Expand Up @@ -165,7 +165,7 @@ const processUser = (user: Users.User) =>
),
)

if (ReadonlyArray.isEmptyArray(decisions)) {
if (Array.isEmptyArray(decisions)) {
return yield* _(Effect.logInfo('Nothing to do'))
}

Expand Down
4 changes: 2 additions & 2 deletions src/Users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ParseResult, Schema } from '@effect/schema'
import { type Cause, Data, Effect, ReadonlyArray, Stream, String, flow } from 'effect'
import { Array, type Cause, Data, Effect, Stream, String, flow } from 'effect'
import * as OrcidId from './OrcidId.js'
import * as Redis from './Redis.js'

Expand All @@ -19,7 +19,7 @@ export const getUsers: Stream.Stream<
}).pipe(
Stream.flattenChunks,
Stream.map(String.split(':')),
Stream.map(ReadonlyArray.lastNonEmpty),
Stream.map(Array.lastNonEmpty),
Stream.flatMap(Schema.decodeEither(OrcidId.OrcidIdSchema)),
Stream.bindTo('orcidId'),
Stream.bind('accessToken', ({ orcidId }) => getAccessToken(orcidId)),
Expand Down
4 changes: 2 additions & 2 deletions src/Zenodo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient } from '@effect/platform'
import { type ParseResult, Schema } from '@effect/schema'
import { Context, Effect, type ReadonlyRecord } from 'effect'
import { Context, Effect, type Record } from 'effect'
import { DoiSchema } from './Doi.js'
import type * as OrcidId from './OrcidId.js'
import * as Temporal from './Temporal.js'
Expand All @@ -27,7 +27,7 @@ export const getReviewsByOrcidId = (orcid: OrcidId.OrcidId) =>
})

const getRecords = (
params: ReadonlyRecord.ReadonlyRecord<string, string>,
params: Record.ReadonlyRecord<string, string>,
): Effect.Effect<Records, GetRecordsForOrcidIdError, ZenodoConfig | HttpClient.client.Client.Default> =>
Effect.gen(function* (_) {
const client = yield* _(zenodoClient)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const HttpClientLive = Layer.succeed(
Effect.annotateLogs({ headers: HttpClient.headers.redact(request.headers, 'authorization') }),
),
),
Effect.zipRight(HttpClient.client.fetch()(request)),
Effect.zipRight(HttpClient.client.fetch(request)),
Effect.tap(response =>
Effect.logDebug('Received HTTP response').pipe(
Effect.annotateLogs({ status: response.status, headers: response.headers }),
Expand Down

0 comments on commit 56da919

Please sign in to comment.