Skip to content

Commit

Permalink
Filter by club reviews
Browse files Browse the repository at this point in the history
Refs #261
  • Loading branch information
thewilkybarkid committed Jan 7, 2025
1 parent 174dbc8 commit 42fb835
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/reviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const chosenType = view(

const chosenCollaborative = view(Inputs.toggle({ label: 'Collaborative' }))

const chosenClub = view(Inputs.toggle({ label: 'In a club' }))

const chosenRequest = view(Inputs.toggle({ label: 'Requested review' }))

const chosenPseudonym = view(Inputs.toggle({ label: 'With a pseudonym' }))
Expand All @@ -74,9 +76,11 @@ const reviewsWithRequest = chosenRequest
? reviewsCollaborative.filter(review => review.requested)
: reviewsCollaborative

const reviewsClub = chosenClub ? reviewsWithRequest.filter(review => review.club) : reviewsWithRequest

const reviewsWithPseudonym = chosenPseudonym
? reviewsWithRequest.filter(review => review.authors.some(author => author.authorType === 'pseudonym'))
: reviewsWithRequest
? reviewsClub.filter(review => review.authors.some(author => author.authorType === 'pseudonym'))
: reviewsClub

const reviewsSelected = chosenType
? reviewsWithPseudonym.filter(review => review.type === chosenType)
Expand All @@ -100,7 +104,7 @@ const languageColor = Plot.scale({
})

const title = capitalize(
`${chosenCollaborative ? 'collaborative ' : ''}${chosenRequest ? 'requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews${chosenPseudonym ? ' using a pseudonym' : ''}`,
`${chosenCollaborative ? 'collaborative ' : ''}${chosenRequest ? 'requested ' : ''}${chosenClub ? 'club ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews${chosenPseudonym ? ' using a pseudonym' : ''}`,
)

const titleWithYear = `${title} ${chosenYear ? ` in ${chosenYear}` : ''}`
Expand All @@ -110,7 +114,7 @@ const titleWithYear = `${title} ${chosenYear ? ` in ${chosenYear}` : ''}`
<div class="card">
<h2>${titleWithYear}</h2>
<span class="big">${reviewsSelected.length.toLocaleString("en-US")}</span>
${chosenCollaborative | chosenPseudonym | chosenRequest | chosenType ? html`
${chosenClub | chosenCollaborative | chosenPseudonym | chosenRequest | chosenType ? html`
<div>${d3.format(".1%")(reviewsSelected.length / reviewsInTimePeriod.length)} of all PREreviews</div>
` : ''}
</div>
Expand Down

0 comments on commit 42fb835

Please sign in to comment.