Skip to content

Commit

Permalink
Filter by reviews that use a pseudonym
Browse files Browse the repository at this point in the history
Refs #50
  • Loading branch information
thewilkybarkid committed Jan 7, 2025
1 parent ff0ae51 commit b49bb4c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/reviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const chosenType = view(
)

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

const chosenPseudonym = view(Inputs.toggle({ label: 'With a pseudonym' }))
```
```js
Expand All @@ -62,10 +64,14 @@ const reviewsInTimePeriod = chosenYear

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

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

const reviewsSelected = chosenType
? reviewsWithPseudonym.filter(review => review.type === chosenType)
: reviewsWithPseudonym

const languageColor = Plot.scale({
color: {
type: 'categorical',
Expand All @@ -86,9 +92,9 @@ const languageColor = Plot.scale({
<div class="grid grid-cols-4">
<div class="card">
<h2>${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews ${chosenYear ? ` in ${chosenYear}` : ''}</h2>
<h2>${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews${chosenPseudonym ? ' using a pseudonym' : ''} ${chosenYear ? ` in ${chosenYear}` : ''}</h2>
<span class="big">${reviewsSelected.length.toLocaleString("en-US")}</span>
${chosenRequest | chosenType ? html`
${chosenPseudonym | chosenRequest | chosenType ? html`
<div>${d3.format(".1%")(reviewsSelected.length / reviewsInTimePeriod.length)} of all PREreviews</div>
` : ''}
</div>
Expand All @@ -97,7 +103,7 @@ const languageColor = Plot.scale({
```js
function reviewsTimeline({ width } = {}) {
return Plot.plot({
title: `${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews per ${chosenYear ? 'week' : 'month'}`,
title: `${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews${chosenPseudonym ? ' using a pseudonym' : ''} per ${chosenYear ? 'week' : 'month'}`,
width: Math.max(width, 600),
height: 400,
color: {
Expand Down Expand Up @@ -144,7 +150,7 @@ function reviewsTimeline({ width } = {}) {
```js
function reviewsByPreprintServer({ width } = {}) {
return Plot.plot({
title: `${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews ${chosenYear ? `in ${chosenYear}` : ''} by preprint server`,
title: `${chosenRequest ? 'Requested ' : ''}${chosenType ? reviewType(chosenType) : ''} PREreviews ${chosenPseudonym ? ' using a pseudonym' : ''} ${chosenYear ? `in ${chosenYear}` : ''} by preprint server`,
width: Math.max(width, 600),
color: {
...languageColor,
Expand Down

0 comments on commit b49bb4c

Please sign in to comment.