Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions components/screening/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ export type Source = {
addedAt: number;
/** The thing it reads, where two can share a name: a Zotero library or one of its collections, a pasted list. */
ref?: string;
/** What it held and the screening doesn't take, each with why, where the form itself read them. */
left?: LeftOut[];
/** How many of the papers it held have no abstract, where they aren't named in `left`. `total` counts none of them. */
bare?: number;
};
/** What finds the words the criteria mark in a text, each with whatever ending the text gives it ("programme" marks "programmes" too). Splitting a text by it leaves the marked words at the odd places. Null with no word to find. */
export function termsPattern(terms: string[]) {
Expand All @@ -154,15 +150,11 @@ export function termsPattern(terms: string[]) {
const UNSPACED = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u;
const JOINED = /\p{Script=Arabic}/u;

/** Why a paper that was found isn't screened. */
const NO_ABSTRACT = "No abstract";
/** How many things a source held that the screening doesn't take. */
export const leftOf = (source: Source) => source.read?.left ?? (source.left?.length ?? 0) + (source.bare ?? 0);
export const leftOf = (source: Source) => source.read?.left ?? 0;
/** How many of those are papers with no abstract. */
export const bareOf = (source: Source) => source.read?.bare ?? (source.bare ?? 0) + (source.left ?? []).filter((one) => one.why === NO_ABSTRACT).length;
export const bareOf = (source: Source) => source.read?.bare ?? 0;
export const leftTotal = (sources: Source[]) => sources.reduce((sum, source) => sum + leftOf(source), 0);
/** Something a source held that isn't screened: a record with no title, a DOI that isn't found, a file with nothing to read. */
export type LeftOut = { name: string; why: string };
/** Sources that gain papers over time, which a living screening checks again. A file or a pasted list holds what it held. */
export const GROWS: SourceKind[] = ["search", "collection", "saved", "screening", "evidenceLibrary", "zotero"];
/** Sources whose papers can come with no abstract and their PDF, which a model is sent whole and charges for by the page. */
Expand All @@ -181,9 +173,15 @@ export const foundTotal = (sources: Source[]) => sources.reduce((sum, source) =>
/** What was removed before screening, named the same on the Overview and in the flow diagram. */
export const REMOVED_LABEL = { merged: "Duplicates merged", bare: "No abstract", unread: "Could not be read or found" } as const;
/** What its sources held that it doesn't screen: what they left out, how much of that for having no abstract, and the duplicates merged. One count for the progress line and the flow. */
export function removedOf(sources: Source[]) {
/**
* What a screening's sources held, as its flow counts them: `found`, every record they gave; `removed`, the ones left
* before screening (duplicates merged, and what was left out, no abstract (`bare`) among it); `kept`, the papers screened.
* The Overview's flow, the diagram and the methods paragraph all count from this.
*/
export function removedOf(sources: Source[], kept = paperTotal(sources)) {
const left = leftTotal(sources);
return { left, bare: sources.reduce((sum, source) => sum + bareOf(source), 0), merged: foundTotal(sources) - paperTotal(sources) };
const merged = foundTotal(sources) - paperTotal(sources);
return { left, bare: sources.reduce((sum, source) => sum + bareOf(source), 0), merged, found: kept + merged + left, removed: merged + left };
}

/** The rule as the pages hold it: the shared one (lib/screening/rules.ts), with how many people read each paper as the text a control holds. */
Expand Down
6 changes: 3 additions & 3 deletions components/screening/dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { inWorkspace, useWorkspace, useWorkspaceAction, useWorkspaceMutation } f
import { changeOpens, changeSays } from "./activity-words";
import { blindOf, modelKey, inOrder, invitedReviewer, lookOf, modelReviewer, modelsOf, peopleOf, personReviewer, type Reviewer } from "./data";
import { gotThrough, theirsOf } from "@/lib/screening/rules";
import { papersHref, reviewerHref } from "./links";
import { papersHref, reviewerHref, bringPartIntoView } from "./links";
import { blindSays, Help, ReviewerMark, ReviewerName, ShutNote } from "./pieces";
import { pdfsOf, perPaper, type Open } from "./store";
import { AddModel } from "./team";
Expand Down Expand Up @@ -95,7 +95,7 @@ export function ActivitySheet({ open, onClose, state }: { open: boolean; onClose
<span className="ms-auto shrink-0 text-xs font-normal text-muted-foreground">{words.ago(change.at)}</span>
</p>
{href ? (
<NextLink href={href} className="-mx-2 flex items-start gap-2 rounded-lg px-2 py-1 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50">
<NextLink href={href} onClick={() => bringPartIntoView(href)} className="-mx-2 flex items-start gap-2 rounded-lg px-2 py-1 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50">
{body}
<ChevronRight aria-hidden className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
</NextLink>
Expand Down Expand Up @@ -262,7 +262,7 @@ export function PeopleDialog({ open, onClose, state, onAdd, onRemove, onDemote }
// Someone invited to vote goes through the same question as anyone added as a reviewer.
invite: (email) => (addAs === "reviewer" ? onAdd(invitedReviewer(email, Date.now())) : void invite({ kind: "screening", id, email, role: "viewer" }).catch(failed)),
// A member typed by address is offered as the member, never invited: an invitation to them can't be sent.
has: (email) => invited.results.some((invitation) => invitation.email === email) || guests.results.some((guest) => guest.email.toLowerCase() === email) || (members?.page ?? []).some((person) => person.email?.toLowerCase() === email),
has: (email) => invited.results.some((invitation) => invitation.email.toLowerCase() === email) || guests.results.some((guest) => guest.email.toLowerCase() === email) || (members?.page ?? []).some((person) => person.email?.toLowerCase() === email),
// The plan's guest places are for people from outside: an organization's own members can still be added as reviewers once they are full.
...(limit !== null && (room?.used ?? 0) >= limit ? (workspace.kind === "organization" && addAs === "reviewer" ? { outsideFull: t("peopleDialog.fullHere", { own: "false", workspace: workspace.name, count: limit }) } : { full: t("peopleDialog.fullHere", { own: String(workspace.kind !== "organization"), workspace: workspace.name, count: limit }) }) : {}),
}
Expand Down
4 changes: 2 additions & 2 deletions components/screening/export-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { Id } from "@/convex/_generated/dataModel";
import { blindOf, reasonCriteria, RESULTS, type Result, slug, bylineOf, questionOf, inOrder, nameOn, votingReviewers } from "./data";
import { papersHref } from "./links";
import { FilterMenu, RESULT_STYLE, EmptyNote, Help, Panel, ShutNote, QuestionName, Reason, ResultChip, ReviewerMark, ReviewerName, Section, VoteMark, OpenPapersChips } from "./pieces";
import { bibOf, everyPaper, papersCsv, recordOf, risOf, save, voteRows, votesCsv, type Taken, fileName, flowOf, flowSvg, methodsOf, PAPER_GUIDE, VOTE_GUIDE } from "./export";
import { bibOf, everyPaper, papersCsv, recordOf, recordReviewers, risOf, save, voteRows, votesCsv, type Taken, fileName, flowOf, flowSvg, methodsOf, PAPER_GUIDE, VOTE_GUIDE } from "./export";
import { useFigures, type Open } from "./store";
import { useWords } from "./words";

Expand Down Expand Up @@ -345,7 +345,7 @@ export function ExportDialog({ open, onClose, state, tab, onTab }: { open: boole
["votes", everyones.votes],
["withoutVote", everyones.yet + everyones.none + everyones.failed],
["criteria", screening.criteria.length],
["reviewers", reviewers.length],
["reviewers", recordReviewers(screening).length],
["sources", screening.sources.length],
["messages", null],
["changes", null],
Expand Down
Loading
Loading