diff --git a/src/reviews.md b/src/reviews.md index d6ab073..3564c0f 100644 --- a/src/reviews.md +++ b/src/reviews.md @@ -12,6 +12,7 @@ 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) }))) @@ -21,6 +22,7 @@ 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 => { @@ -51,6 +53,8 @@ const chosenType = view( format: type => reviewType(type) ?? 'All', }), ) + +const chosenRequest = view(Inputs.toggle({ label: 'Requested review' })) ``` ```js @@ -58,10 +62,14 @@ const reviewsInTimePeriod = chosenYear ? reviews.filter(review => review.createdAt.getUTCFullYear() === chosenYear) : reviews -const reviewsSelected = chosenType - ? reviewsInTimePeriod.filter(review => review.type === chosenType) +const reviewsWithRequest = chosenRequest + ? reviewsInTimePeriod.filter(review => preprintsWithRequest.has(review.preprint)) : reviewsInTimePeriod +const reviewsSelected = chosenType + ? reviewsWithRequest.filter(review => review.type === chosenType) + : reviewsWithRequest + const languageColor = Plot.scale({ color: { type: 'categorical', @@ -82,9 +90,9 @@ const languageColor = Plot.scale({