Skip to content

Commit

Permalink
Allow loading PREreviews for a pseudonym
Browse files Browse the repository at this point in the history
Refs #976
  • Loading branch information
thewilkybarkid committed Jun 1, 2023
1 parent f89345c commit 0aea7d9
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 130 deletions.
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import {
import {
createRecordOnZenodo,
getPrereviewFromZenodo,
getPrereviewsForOrcidFromZenodo,
getPrereviewsForProfileFromZenodo,
getPrereviewsFromZenodo,
getRecentPrereviewsFromZenodo,
} from './zenodo'
Expand Down Expand Up @@ -374,7 +374,7 @@ export const router: P.Parser<RM.ReaderMiddleware<AppEnv, StatusOpen, ResponseEn
R.local((env: AppEnv) => ({
...env,
getName: flip(getNameFromOrcid)(env),
getPrereviews: flip(getPrereviewsForOrcidFromZenodo)({
getPrereviews: flip(getPrereviewsForProfileFromZenodo)({
...env,
getPreprintTitle: flow(
flip(getPreprintTitle)(env),
Expand Down
11 changes: 8 additions & 3 deletions src/zenodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import iso6391, { type LanguageCode } from 'iso-639-1'
import iso6393To1 from 'iso-639-3/to-1.json'
import * as L from 'logger-fp-ts'
import type { Orcid } from 'orcid-id-ts'
import { isOrcid } from 'orcid-id-ts'
import { get } from 'spectacles-ts'
import { P, match } from 'ts-pattern'
import {
Expand All @@ -37,6 +38,7 @@ import type { RecentPrereview } from './home'
import { plainText, sanitizeHtml } from './html'
import { type GetPreprintEnv, type GetPreprintTitleEnv, getPreprint, getPreprintTitle } from './preprint'
import { type IndeterminatePreprintId, PreprintDoiD, type PreprintId, fromPreprintDoi, fromUrl } from './preprint-id'
import { type Pseudonym, isPseudonym } from './pseudonym'
import type { Prereview } from './review'
import type { NewPrereview } from './write-review'

Expand Down Expand Up @@ -102,11 +104,14 @@ export const getPrereviewFromZenodo = flow(
RTE.chain(recordToPrereview),
)

export const getPrereviewsForOrcidFromZenodo = flow(
(orcid: Orcid) =>
export const getPrereviewsForProfileFromZenodo = flow(
(profile: Orcid | Pseudonym) =>
new URLSearchParams({
communities: 'prereview-reviews',
q: `creators.orcid:${orcid}`,
q: match(profile)
.when(isOrcid, orcid => `creators.orcid:${orcid}`)
.when(isPseudonym, pseudonym => `creators.name:"${pseudonym}"`)
.exhaustive(),
size: '100',
sort: '-publication_date',
subtype: 'peerreview',
Expand Down
Loading

0 comments on commit 0aea7d9

Please sign in to comment.