Skip to content

Commit

Permalink
Push up hard-coded data
Browse files Browse the repository at this point in the history
Refs #976
  • Loading branch information
thewilkybarkid committed May 30, 2023
1 parent 4953776 commit 9e4297a
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 112 deletions.
114 changes: 4 additions & 110 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand All @@ -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'
Expand Down Expand Up @@ -111,12 +109,11 @@ import {
import {
createRecordOnZenodo,
getPrereviewFromZenodo,
getPrereviewsForOrcidFromZenodo,
getPrereviewsFromZenodo,
getRecentPrereviewsFromZenodo,
} from './zenodo'

import PlainDate = Temporal.PlainDate

export type AppEnv = FathomEnv &
FormStoreEnv &
GhostApiEnv &
Expand Down Expand Up @@ -364,111 +361,8 @@ export const router: P.Parser<RM.ReaderMiddleware<AppEnv, StatusOpen, ResponseEn
P.map(
R.local((env: AppEnv) => ({
...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 <i>trans</i>`,
},
},
{
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 <i>Agaricus bisporus</i> 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),
})),
),
Expand Down
3 changes: 3 additions & 0 deletions src/orcid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as TE from 'fp-ts/TaskEither'

export const getNameFromOrcid = () => TE.of('Daniela Saderi')
2 changes: 1 addition & 1 deletion src/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>
readonly published: PlainDate
Expand Down
107 changes: 106 additions & 1 deletion src/zenodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -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 <i>trans</i>`,
},
},
{
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 <i>Agaricus bisporus</i> 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({
Expand Down
10 changes: 10 additions & 0 deletions test/orcid.ts
Original file line number Diff line number Diff line change
@@ -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'))
})
6 changes: 6 additions & 0 deletions test/zenodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 9e4297a

Please sign in to comment.