Skip to content

Commit

Permalink
Show the number of reviews published by new joiners using their publi…
Browse files Browse the repository at this point in the history
…c pseudonym

Refs #43
  • Loading branch information
thewilkybarkid committed Aug 16, 2024
1 parent c2e3e82 commit bd41989
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions src/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ const reviewType = id => {
const users = FileAttachment('./data/users.json')
.json()
.then(data => data.map(user => ({ ...user, timestamp: parseTimestamp(user.timestamp) })))
const reviews = FileAttachment('./data/reviews.json')
.json()
.then(data => data.map(review => ({ ...review, createdAt: parseDate(review.createdAt) })))
const reviews = Promise.all([users, FileAttachment('./data/reviews.json').json()]).then(([users, data]) =>
data.map(review => ({
...review,
createdAt: parseDate(review.createdAt),
authors: review.authors.map(author => ({
...author,
joined: author.authorType === 'public' ? users.find(user => user.orcid === author.author)?.timestamp : undefined,
})),
})),
)
```
```js
Expand Down Expand Up @@ -103,6 +110,10 @@ const reviewsByAuthor = d3.rollup(
d => `${d.authorType}:${d.author}`,
)

const reviewsByAuthorInTimePeriod = new Map(
reviewsByAuthor.entries().filter(([id]) => usersInTimePeriod.some(user => `public:${user.orcid}` === id)),
)

const careerStageColor = Plot.scale({
color: {
type: 'categorical',
Expand All @@ -115,6 +126,11 @@ const usersWithAtLeast1ReviewPublished = d3.sum(reviewsByAuthor, d => (d[1] >= 1
const usersWith1ReviewPublished = d3.sum(reviewsByAuthor, d => (d[1] === 1 ? 1 : 0))
const usersWithMoreThan1ReviewsPublished = d3.sum(reviewsByAuthor, d => (d[1] > 1 ? 1 : 0))
const usersWithMoreThan3ReviewsPublished = d3.sum(reviewsByAuthor, d => (d[1] > 3 ? 1 : 0))

const usersInTimePeriodWithAtLeast1ReviewPublished = d3.sum(reviewsByAuthorInTimePeriod, d => (d[1] >= 1 ? 1 : 0))
const usersInTimePeriodWith1ReviewPublished = d3.sum(reviewsByAuthorInTimePeriod, d => (d[1] === 1 ? 1 : 0))
const usersInTimePeriodWithMoreThan1ReviewsPublished = d3.sum(reviewsByAuthorInTimePeriod, d => (d[1] > 1 ? 1 : 0))
const usersInTimePeriodWithMoreThan3ReviewsPublished = d3.sum(reviewsByAuthorInTimePeriod, d => (d[1] > 3 ? 1 : 0))
```
<div class="grid grid-cols-4">
Expand Down Expand Up @@ -151,6 +167,35 @@ const usersWithMoreThan3ReviewsPublished = d3.sum(reviewsByAuthor, d => (d[1] >
</tr>
</table>
</div>
<div class="card">
<h2>PREreviewers ${chosenYear ? ` joining in ${chosenYear}` : ''} with ${chosenType ? reviewType(chosenType) : ''} PREreviews published using their public pseudonym ${chosenYear ? ` in ${chosenYear}` : ''}</h2>
<table>
<colgroup>
<col>
<col span="2" style="width: 5em">
</colgroup>
<tr class="highlight">
<th>At least 1</th>
<td class="numeric">${usersInTimePeriodWithAtLeast1ReviewPublished.toLocaleString('en-US')}</td>
<td class="numeric">${usersInTimePeriod.length > 0 ? d3.format(".1%")(usersInTimePeriodWithAtLeast1ReviewPublished / usersInTimePeriod.length) : ''}</td>
</tr>
<tr>
<th>Only 1</th>
<td class="numeric">${usersInTimePeriodWith1ReviewPublished.toLocaleString('en-US')}</td>
<td class="numeric">${usersInTimePeriod.length > 0 ? d3.format(".1%")(usersInTimePeriodWith1ReviewPublished / usersInTimePeriod.length) : ''}</td>
</tr>
<tr>
<th>More than 1</th>
<td class="numeric">${usersInTimePeriodWithMoreThan1ReviewsPublished.toLocaleString('en-US')}</td>
<td class="numeric">${usersInTimePeriod.length > 0 ? d3.format(".1%")(usersInTimePeriodWithMoreThan1ReviewsPublished / usersInTimePeriod.length) : ''}</td>
</tr>
<tr>
<th>More than 3</th>
<td class="numeric">${usersInTimePeriodWithMoreThan3ReviewsPublished.toLocaleString('en-US')}</td>
<td class="numeric">${usersInTimePeriod.length > 0 ? d3.format(".1%")(usersInTimePeriodWithMoreThan3ReviewsPublished / usersInTimePeriod.length) : ''}</td>
</tr>
</table>
</div>
</div>
```js
Expand Down

0 comments on commit bd41989

Please sign in to comment.