Skip to content

Commit

Permalink
Only count reviews published after the request
Browse files Browse the repository at this point in the history
Refs #26
  • Loading branch information
thewilkybarkid committed Aug 30, 2024
1 parent 4b67acd commit e72f6b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/data/reviews.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Reviews = Schema.Array(
preprint: Doi.ParseDoiSchema,
language: Schema.OptionFromUndefinedOr(LanguageCode.LanguageCodeSchema),
live: Schema.Boolean,
requested: Schema.Boolean,
server: PreprintServer.PreprintServerSchema,
type: Schema.Literal('full', 'structured', 'rapid'),
}),
Expand Down Expand Up @@ -96,6 +97,7 @@ const getLegacyRapidReviews = Effect.gen(function* () {
language: Option.some('en'),
live: false,
preprint: review.preprint.handle,
requested: false,
server: review.preprint.preprintServer,
type: 'rapid',
}) satisfies Schema.Schema.Type<typeof Reviews>[number],
Expand All @@ -122,6 +124,7 @@ const getLegacyReviews = Effect.gen(function* () {
language: Option.some('en'),
live: false,
preprint: review.preprint.handle,
requested: false,
server: review.preprint.preprintServer,
type: 'full',
}) satisfies Schema.Schema.Type<typeof Reviews>[number],
Expand Down
6 changes: 1 addition & 5 deletions src/reviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const languageNames = new Intl.DisplayNames(['en-US'], { type: 'language' })
const languageName = code => (code ? languageNames.of(code) : 'Unknown')

const preprintServers = FileAttachment('./data/preprint-servers.json').json()
const requests = FileAttachment('./data/requests.json').json()
const reviews = FileAttachment('./data/reviews.json')
.json()
.then(data => data.map(review => ({ ...review, createdAt: parseDate(review.createdAt) })))
Expand All @@ -22,7 +21,6 @@ const reviews = FileAttachment('./data/reviews.json')
const now = new Date()
const firstReview = d3.min(reviews, review => review.createdAt)

const preprintsWithRequest = new d3.InternSet(d3.group(requests, request => request.preprint).keys())
const preprintServerName = id => preprintServers[id]

const reviewType = id => {
Expand Down Expand Up @@ -62,9 +60,7 @@ const reviewsInTimePeriod = chosenYear
? reviews.filter(review => review.createdAt.getUTCFullYear() === chosenYear)
: reviews

const reviewsWithRequest = chosenRequest
? reviewsInTimePeriod.filter(review => preprintsWithRequest.has(review.preprint))
: reviewsInTimePeriod
const reviewsWithRequest = chosenRequest ? reviewsInTimePeriod.filter(review => review.requested) : reviewsInTimePeriod

const reviewsSelected = chosenType
? reviewsWithRequest.filter(review => review.type === chosenType)
Expand Down

0 comments on commit e72f6b4

Please sign in to comment.