diff --git a/src/users.md b/src/users.md index 9f17ca8..22aac68 100644 --- a/src/users.md +++ b/src/users.md @@ -71,6 +71,15 @@ const reviewsInTimePeriod = chosenYear ? reviews.filter(review => review.createdAt.getUTCFullYear() === chosenYear) : reviews +const userReviews = reviewsInTimePeriod.flatMap(({ authors, ...review }) => + authors.map(author => ({ ...review, ...author })), +) +const reviewsByAuthor = d3.rollup( + userReviews, + d => d.length, + d => `${d.authorType}:${d.author}`, +) + const careerStageColor = Plot.scale({ color: { type: 'categorical', @@ -85,14 +94,31 @@ const careerStageColor = Plot.scale({
At least 1 | +${d3.sum(reviewsByAuthor, d => d[1] >= 1 ? 1 : 0).toLocaleString('en-US')} | +
---|---|
Only 1 | +${d3.sum(reviewsByAuthor, d => d[1] === 1 ? 1 : 0).toLocaleString('en-US')} | +
More than 1 | +${d3.sum(reviewsByAuthor, d => d[1] > 1 ? 1 : 0).toLocaleString('en-US')} | +
More than 3 | +${d3.sum(reviewsByAuthor, d => d[1] > 3 ? 1 : 0).toLocaleString('en-US')} | +