From 9e4297ac61bf09aa053a7a0d4a7aecea7629b763 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 30 May 2023 12:06:28 +0100 Subject: [PATCH] Push up hard-coded data Refs #976 --- src/app.ts | 114 ++------------------------------------------ src/orcid.ts | 3 ++ src/profile.ts | 2 +- src/zenodo.ts | 107 ++++++++++++++++++++++++++++++++++++++++- test/orcid.ts | 10 ++++ test/zenodo.test.ts | 6 +++ 6 files changed, 130 insertions(+), 112 deletions(-) create mode 100644 src/orcid.ts create mode 100644 test/orcid.ts diff --git a/src/app.ts b/src/app.ts index 10391df15..f2e1fa63f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,3 @@ -import { Temporal } from '@js-temporal/polyfill' -import type { Doi } from 'doi-ts' import express from 'express' import * as P from 'fp-ts-routing' import type { Json } from 'fp-ts/Json' @@ -36,7 +34,6 @@ import { findAPreprint } from './find-a-preprint' import { funding } from './funding' import type { GhostApiEnv } from './ghost' import { home } from './home' -import { html } from './html' import { handleError } from './http-error' import { type LegacyPrereviewApiEnv, @@ -49,6 +46,7 @@ import { import { getPreprintIdFromLegacyPreviewUuid } from './legacy-prereview' import { legacyRoutes } from './legacy-routes' import { authenticate, authenticateError, logIn, logOut } from './log-in' +import { getNameFromOrcid } from './orcid' import type { FathomEnv, PhaseEnv } from './page' import { partners } from './partners' import { getPreprintFromPhilsci } from './philsci' @@ -111,12 +109,11 @@ import { import { createRecordOnZenodo, getPrereviewFromZenodo, + getPrereviewsForOrcidFromZenodo, getPrereviewsFromZenodo, getRecentPrereviewsFromZenodo, } from './zenodo' -import PlainDate = Temporal.PlainDate - export type AppEnv = FathomEnv & FormStoreEnv & GhostApiEnv & @@ -364,111 +361,8 @@ export const router: P.Parser ({ ...env, - getName: () => TE.of('Daniela Saderi'), - getPrereviews: () => - TE.of([ - { - id: 6577344, - reviewers: ['Ahmet Bakirbas', 'Allison Barnes', 'JOHN LILLY JIMMY', 'Daniela Saderi', 'ARPITA YADAV'], - published: PlainDate.from('2022-05-24'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/2021.06.10.447945' as Doi<'1101'> }, - language: 'en', - title: html`Ovule siRNAs methylate protein-coding genes in trans`, - }, - }, - { - id: 6323771, - reviewers: [ - 'JOHN LILLY JIMMY', - 'Priyanka Joshi', - 'Dilip Kumar', - 'Neha Nandwani', - 'Ritam Neupane', - 'Ailis OCarroll', - 'Guto Rhys', - 'Javier Aguirre Rivera', - 'Daniela Saderi', - 'Mohammad Salehin', - 'Agata Witkowska', - ], - published: PlainDate.from('2022-03-02'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/2021.11.05.467508' as Doi<'1101'> }, - language: 'en', - title: html`Biochemical analysis of deacetylase activity of rice sirtuin OsSRT1, a class IV member in - plants`, - }, - }, - { - id: 5767994, - reviewers: [ - 'Daniela Saderi', - 'Sonisilpa Mohapatra', - 'Nikhil Bhandarkar', - 'Antony Gruness', - 'Isha Soni', - 'Iratxe Puebla', - 'Jessica Polka', - ], - published: PlainDate.from('2021-12-08'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/2021.10.21.465111' as Doi<'1101'> }, - language: 'en', - title: html`Assessment of Agaricus bisporus Mushroom as Protective Agent Against Ultraviolet - Exposure`, - }, - }, - { - id: 5551162, - reviewers: [ - 'Daniela Saderi', - 'Katrina Murphy', - 'Leire Abalde-Atristain', - 'Cole Brashaw', - 'Robin Elise Champieux', - 'PREreview.org community member', - ], - published: PlainDate.from('2021-10-05'), - preprint: { - id: { type: 'medrxiv', value: '10.1101/2021.07.28.21260814' as Doi<'1101'> }, - language: 'en', - title: html`Influence of social determinants of health and county vaccination rates on machine - learning models to predict COVID-19 case growth in Tennessee`, - }, - }, - { - id: 7621712, - reviewers: ['Daniela Saderi'], - published: PlainDate.from('2018-09-06'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/410472' as Doi<'1101'> }, - language: 'en', - title: html`EMT network-based feature selection improves prognosis prediction in lung adenocarcinoma`, - }, - }, - { - id: 7621012, - reviewers: ['Daniela Saderi'], - published: PlainDate.from('2017-09-28'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/193268' as Doi<'1101'> }, - language: 'en', - title: html`Age-related decline in behavioral discrimination of amplitude modulation frequencies - compared to envelope-following responses`, - }, - }, - { - id: 7620977, - reviewers: ['Daniela Saderi'], - published: PlainDate.from('2017-04-10'), - preprint: { - id: { type: 'biorxiv', value: '10.1101/124750' as Doi<'1101'> }, - language: 'en', - title: html`Cortical Representations of Speech in a Multi-talker Auditory Scene`, - }, - }, - ]), + getName: getNameFromOrcid, + getPrereviews: getPrereviewsForOrcidFromZenodo, getUser: () => pipe(getSession(), chainOptionKW(() => 'no-session' as const)(getUserFromSession))(env), })), ), diff --git a/src/orcid.ts b/src/orcid.ts new file mode 100644 index 000000000..0c2d294e2 --- /dev/null +++ b/src/orcid.ts @@ -0,0 +1,3 @@ +import * as TE from 'fp-ts/TaskEither' + +export const getNameFromOrcid = () => TE.of('Daniela Saderi') diff --git a/src/profile.ts b/src/profile.ts index 5ce36a0be..f012e9ba4 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -20,7 +20,7 @@ import { type User, maybeGetUser } from './user' import PlainDate = Temporal.PlainDate -type Prereviews = RNEA.ReadonlyNonEmptyArray<{ +export type Prereviews = RNEA.ReadonlyNonEmptyArray<{ readonly id: number readonly reviewers: RNEA.ReadonlyNonEmptyArray readonly published: PlainDate diff --git a/src/zenodo.ts b/src/zenodo.ts index 513abca3a..06d2c62f1 100644 --- a/src/zenodo.ts +++ b/src/zenodo.ts @@ -12,6 +12,7 @@ import type { ReaderTaskEither } from 'fp-ts/ReaderTaskEither' import * as RA from 'fp-ts/ReadonlyArray' import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray' import * as RR from 'fp-ts/ReadonlyRecord' +import * as TE from 'fp-ts/TaskEither' import { flow, identity, pipe } from 'fp-ts/function' import { NotFound } from 'http-errors' import { Status } from 'hyper-ts' @@ -33,9 +34,10 @@ import { } from 'zenodo-ts' import { revalidateIfStale, timeoutRequest, useStaleCache } from './fetch' import type { RecentPrereview } from './home' -import { plainText, sanitizeHtml } from './html' +import { html, 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 { Prereviews } from './profile' import type { Prereview } from './review' import type { NewPrereview } from './write-review' @@ -101,6 +103,109 @@ export const getPrereviewFromZenodo = flow( RTE.chain(recordToPrereview), ) +export const getPrereviewsForOrcidFromZenodo = () => + TE.of([ + { + id: 6577344, + reviewers: ['Ahmet Bakirbas', 'Allison Barnes', 'JOHN LILLY JIMMY', 'Daniela Saderi', 'ARPITA YADAV'], + published: PlainDate.from('2022-05-24'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/2021.06.10.447945' as Doi<'1101'> }, + language: 'en', + title: html`Ovule siRNAs methylate protein-coding genes in trans`, + }, + }, + { + id: 6323771, + reviewers: [ + 'JOHN LILLY JIMMY', + 'Priyanka Joshi', + 'Dilip Kumar', + 'Neha Nandwani', + 'Ritam Neupane', + 'Ailis OCarroll', + 'Guto Rhys', + 'Javier Aguirre Rivera', + 'Daniela Saderi', + 'Mohammad Salehin', + 'Agata Witkowska', + ], + published: PlainDate.from('2022-03-02'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/2021.11.05.467508' as Doi<'1101'> }, + language: 'en', + title: html`Biochemical analysis of deacetylase activity of rice sirtuin OsSRT1, a class IV member in plants`, + }, + }, + { + id: 5767994, + reviewers: [ + 'Daniela Saderi', + 'Sonisilpa Mohapatra', + 'Nikhil Bhandarkar', + 'Antony Gruness', + 'Isha Soni', + 'Iratxe Puebla', + 'Jessica Polka', + ], + published: PlainDate.from('2021-12-08'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/2021.10.21.465111' as Doi<'1101'> }, + language: 'en', + title: html`Assessment of Agaricus bisporus Mushroom as Protective Agent Against Ultraviolet Exposure`, + }, + }, + { + id: 5551162, + reviewers: [ + 'Daniela Saderi', + 'Katrina Murphy', + 'Leire Abalde-Atristain', + 'Cole Brashaw', + 'Robin Elise Champieux', + 'PREreview.org community member', + ], + published: PlainDate.from('2021-10-05'), + preprint: { + id: { type: 'medrxiv', value: '10.1101/2021.07.28.21260814' as Doi<'1101'> }, + language: 'en', + title: html`Influence of social determinants of health and county vaccination rates on machine learning models + to predict COVID-19 case growth in Tennessee`, + }, + }, + { + id: 7621712, + reviewers: ['Daniela Saderi'], + published: PlainDate.from('2018-09-06'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/410472' as Doi<'1101'> }, + language: 'en', + title: html`EMT network-based feature selection improves prognosis prediction in lung adenocarcinoma`, + }, + }, + { + id: 7621012, + reviewers: ['Daniela Saderi'], + published: PlainDate.from('2017-09-28'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/193268' as Doi<'1101'> }, + language: 'en', + title: html`Age-related decline in behavioral discrimination of amplitude modulation frequencies compared to + envelope-following responses`, + }, + }, + { + id: 7620977, + reviewers: ['Daniela Saderi'], + published: PlainDate.from('2017-04-10'), + preprint: { + id: { type: 'biorxiv', value: '10.1101/124750' as Doi<'1101'> }, + language: 'en', + title: html`Cortical Representations of Speech in a Multi-talker Auditory Scene`, + }, + }, + ] satisfies Prereviews) + export const getPrereviewsFromZenodo = flow( (preprint: PreprintId) => new URLSearchParams({ diff --git a/test/orcid.ts b/test/orcid.ts new file mode 100644 index 000000000..87bd1285e --- /dev/null +++ b/test/orcid.ts @@ -0,0 +1,10 @@ +import { test } from '@fast-check/jest' +import { expect } from '@jest/globals' +import * as E from 'fp-ts/Either' +import * as _ from '../src/orcid' + +test('getNameFromOrcid', async () => { + const actual = await _.getNameFromOrcid()() + + expect(actual).toStrictEqual(E.right('Daniela Saderi')) +}) diff --git a/test/zenodo.test.ts b/test/zenodo.test.ts index 439b1b447..ab22c34af 100644 --- a/test/zenodo.test.ts +++ b/test/zenodo.test.ts @@ -1245,6 +1245,12 @@ describe('getPrereviewFromZenodo', () => { }) }) +test('getPrereviewsForOrcidFromZenodo', async () => { + const actual = await _.getPrereviewsForOrcidFromZenodo()() + + expect(actual).toStrictEqual(E.right(expect.anything())) +}) + describe('getPrereviewsFromZenodo', () => { test.prop([fc.preprintId()])('when the PREreviews can be loaded', async preprint => { const records: Records = {