diff --git a/components/screening/data.ts b/components/screening/data.ts index 2d277f521..25e74e9b6 100644 --- a/components/screening/data.ts +++ b/components/screening/data.ts @@ -25,7 +25,7 @@ export { SOMEONE }; /** A reviewer's name where there is little room: a person's first name, and a model's whole name, since its first word alone only names its maker. */ export const shortName = (reviewer: { kind: "person" | "model"; name: string; email?: string }) => (reviewer.kind === "person" && !reviewer.email ? firstName(reviewer.name) : reviewer.name); /** A name as part of a file's name or an address. */ -export const slug = (name: string) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""); +export const slug = (name: string) => name.normalize("NFC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu, "-").replace(/^-|-$/g, ""); /** A number as people read it: "1,204". */ export const num = (n: number) => n.toLocaleString("en-GB"); /** A small number as a word at the start of a sentence: "Three of the 5 reviewers". */ @@ -188,7 +188,7 @@ export function removedOf(sources: Source[], kept = paperTotal(sources)) { export type Rule = Omit & { each: `${number}` | "all"; models: NonNullable }; /** What each answer to a criterion is worth, yes, no and unclear, and the points each star starts at. Points only make stars: no vote follows from them. */ export type Scoring = { points: Record; stars: number[] }; -export type WriteProblem = "role" | "notFound" | "unreadable"; +export type WriteProblem = "role" | "notFound" | "unreadable" | "full"; export type Destination = { kind: "none" | "new" | "collection" | "community"; name: string; collection?: string; prune: boolean; /** A community that refused or didn't answer the last write of included papers, adding them or taking them out, until one gets through. */ problem?: WriteProblem; pruneProblem?: WriteProblem; /** In a community: which one, and the collection of the person's there, or a new one of theirs to make (`collection: "new"`). */ community?: { libraryId: string; collection: string; private: boolean; requestId: string } }; /** Why a paper is excluded when no criterion is the reason: shown after the criteria in the list of reasons. */ diff --git a/components/screening/export-dialog.tsx b/components/screening/export-dialog.tsx index 842d4cd9d..f3c75e9e2 100644 --- a/components/screening/export-dialog.tsx +++ b/components/screening/export-dialog.tsx @@ -28,6 +28,7 @@ import { showStyledToast } from "@/components/ui/sonner"; import { Spinner } from "@/components/ui/spinner"; import { api } from "@/convex/_generated/api"; import { useCursorPage } from "@/lib/hooks/use-cursor-page"; +import { EMAILED_FILES_BYTES } from "@/lib/export"; import { getErrorMessage } from "@/lib/toast/use-app-toast"; import { inWorkspace, useWorkspace as usePageWorkspace, useWorkspaceAction } from "@/lib/workspaces/url"; import type { Id } from "@/convex/_generated/dataModel"; @@ -408,6 +409,8 @@ function SendFiles({ jobId, files }: { jobId: string; files: Array<{ format: str setBusy(true); try { const made = await Promise.all(chosen.map((one) => one.make())); + // Files too large for one email together are said to be before they go: the server would refuse them, or the request never reach it. + if (new TextEncoder().encode(JSON.stringify(made)).length > EMAILED_FILES_BYTES) return void showStyledToast("error", t("send.tooLarge", { count: made.length })); await sendFiles({ jobId: jobId as Id<"screeningJobs">, to: to.trim(), files: made, ...(note.trim() ? { note: note.trim() } : {}) }); toast(t("send.sent", { to: to.trim(), count: made.length })); setOpen(false); diff --git a/components/screening/export.ts b/components/screening/export.ts index bb14fd475..934cd9732 100644 --- a/components/screening/export.ts +++ b/components/screening/export.ts @@ -4,7 +4,7 @@ // same rows, and what is hidden from someone on a page is hidden from them in every file. import type { ConvexReactClient } from "convex/react"; -import { hidesVotes, modelsAdvise } from "@/lib/screening/rules"; +import { hidesVotes, modelsAdvise, OTHER_REASON } from "@/lib/screening/rules"; import { effortOf } from "@/components/settings/model-map"; import type { EFFORTS } from "@/lib/ai/core/call-options"; import { api } from "@/convex/_generated/api"; @@ -79,6 +79,9 @@ const filedOf = (sources: Screening["sources"]) => sources.reduce((sum, source) /** A source's set as a file gives it: an upload's, a list's or a drop's handle opens nothing outside the app, so it is left out. */ /** Everyone the whole record lists as a reviewer: all who were on the screening, taken off or not; someone invited who never joined is counted apart. */ export const recordReviewers = (screening: Pick) => screening.reviewers.filter((reviewer) => !reviewer.email); +/** Who sees a vote before casting their own, as the record says it of the rule now and of each version before. */ +const HIDDEN_SEEN = "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished"; +const ADVICE_SEEN = "People's votes are hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished. The AI models' votes are advice, and show to a reviewer before they vote"; const withoutFiles = (set: NonNullable) => { const { file: _file, batch: _batch, ...rest } = set as typeof set & { file?: unknown; batch?: unknown }; return rest; @@ -176,7 +179,8 @@ export function paperRows({ screening }: Pick, papers: Paper source: screening.sources.find((source) => source.id === paper.source)?.name ?? "", added: paper.addedAt === undefined ? "At the start" : iso(paper.addedAt), result: RESULT_LABEL[settled.result], - excluded_for: settled.result === "exclude" && paper.reason ? failedLabel(paper.reason, reasonCriteria(screening)) : "", + // Another reason carries what was written for it: the settler's words, else the voter's. + excluded_for: settled.result === "exclude" && paper.reason ? [failedLabel(paper.reason, reasonCriteria(screening)), ...(paper.reason === OTHER_REASON ? [settled.resolvedBy ? settled.note : paper.cast.find((one) => one.vote?.reason === OTHER_REASON && one.vote?.note)?.vote?.note].filter(Boolean).map((text) => `"${text}"`) : [])].join(", ") : "", settled_by: settled.resolvedBy ? nameOn(screening, settled.resolvedBy) : "", settled_note: settled.note ?? "", votes_include: how("include"), @@ -474,7 +478,8 @@ export function methodsOf(out: Taken) { changed ? `The settings or the reviewers were changed ${changed === 1 ? "once" : `${changed} times`} after screening began${changedParts.length ? ` (${listed(changedParts)})` : ""}. The screening's exported record lists each change and what it did.` : "", pair ? `Agreement between ${pairOn![0].name} and ${pairOn![1].name} over the ${pair.papers} records both assessed was ${Math.round(pair.same * 100)}% (${pair.kappa === null ? "Cohen's kappa could not be estimated, as both gave the same decision every time" : `Cohen's kappa ${pair.kappa.toFixed(2)}`}).` : "", kappas.length > 1 ? `Across the ${kappas.length} pairs of reviewers with a value${modelPairs ? `, ${modelPairs} among them` : ""}, pairwise agreement (Cohen's kappa) ranged from ${kappas[0]!.toFixed(2)} to ${kappas.at(-1)!.toFixed(2)}${alike ? `; ${alike === 1 ? "one other pair" : `${alike} other pairs`} gave the same decision on every record they shared, so kappa has no value for ${alike === 1 ? "it" : "them"}` : ""}.` : "", - `${plural(counts.include, "record was", "records were")} included${counts.maybe ? `, and ${plural(counts.maybe, "was", "were")} left at Maybe` : ""}.`, + // Where the records stand: included, and the excluded and Maybe ones where there are any. + `${listed([`${plural(counts.include, "record was", "records were")} included`, ...(counts.exclude ? [`${num(counts.exclude)} excluded`] : []), ...(counts.maybe ? [`${num(counts.maybe)} left at Maybe`] : [])])}.`, ].filter(Boolean).join(" "); } @@ -504,8 +509,8 @@ export async function recordOf(convex: ConvexReactClient, workspaceId: Id<"works const rows = voteRows(screening, papers); const hidden = { votes: rows.filter((row) => row.kept).length, papers: new Set(rows.flatMap((row) => (row.kept ? [row.paper.id] : []))).size }; // A rule and a criterion, said one way wherever the file says them: as they stand now, and in each version of the history. - // A version of the history is said from its own rule alone: who reviewed then isn't kept, and today's reviewers say nothing of it. - const ruleOut = (rule: Rule, now = true) => ({ people_on_each_paper: rule.each === "all" ? "Everyone" : eachOf(rule), settled_when: SETTLE_LABEL[rule.settle], models_votes: now && !modelsOf(screening).length ? null : rule.settle === "one" ? "Advice on papers a person has" : rule.models === "advice" ? "Advice only" : "Count like a person's", conflicts_settled_by: rule.settle === "one" ? null : nameOn(screening, rule.resolver), other_votes_seen: rule.blind !== "after" ? "At any time" : !now ? "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished" : !hidesVotes(rule, hidingReaders(screening, out.invited), modelsVoting(screening)) ? (modelsVoting(screening) ? "At any time, since one person reads each paper and the AI models' votes are advice" : "At any time, since one person reads each paper") : advisedIn(screening, out.invited) ? "People's votes are hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished. The AI models' votes are advice, and show to a reviewer before they vote" : "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished" }); + // A version of the history is said from its own rule and the models that were on the screening while it stood (`span`, from it to the next): who else reviewed then isn't kept. + const ruleOut = (rule: Rule, span?: readonly [number, number]) => { const now = !span; const modelsThen = span ? screening.reviewers.filter((one) => one.kind === "model" && one.addedAt < span[1] && (one.left === undefined || one.left > span[0])).length : 0; return ({ people_on_each_paper: rule.each === "all" ? "Everyone" : eachOf(rule), settled_when: SETTLE_LABEL[rule.settle], models_votes: (now ? !modelsOf(screening).length : !modelsThen) ? null : rule.settle === "one" ? "Advice on papers a person has" : rule.models === "advice" ? "Advice only" : "Count like a person's", conflicts_settled_by: rule.settle === "one" ? null : nameOn(screening, rule.resolver), other_votes_seen: rule.blind !== "after" ? "At any time" : !now ? (modelsThen && (rule.settle === "one" || rule.models === "advice") ? ADVICE_SEEN : HIDDEN_SEEN) : !hidesVotes(rule, hidingReaders(screening, out.invited), modelsVoting(screening)) ? (modelsVoting(screening) ? "At any time, since one person reads each paper and the AI models' votes are advice" : "At any time, since one person reads each paper") : advisedIn(screening, out.invited) ? ADVICE_SEEN : HIDDEN_SEEN }); }; const criterionOut = (criterion: Omit, [yes, no, unclear]: readonly number[]) => ({ key: criterion.key, short_name: criterion.short, question: criterion.text, must_have: criterion.must, guidance: criterion.note ?? null, marked_words: criterion.terms, points: { yes, no, unclear } }); // What a part of the screening carries from before it began is dated from its start. const since = (when: number) => iso(Math.max(when, screening.createdAt)); @@ -537,11 +542,11 @@ export async function recordOf(convex: ConvexReactClient, workspaceId: Id<"works sources: screening.sources.map((source, at) => ({ id: source.id, kind: source.kind, name: source.name, detail: source.detail, set: source.set ? withoutFiles(source.set) : null, filters: source.filters ?? [], records_taken: source.scope === "range" ? { first: source.range[0], last: source.range[1] } : "all", last_checked_at: source.read?.checkedAt ? iso(source.read.checkedAt) : null, last_read_failed: source.read?.state === "failed" ? (source.read.failure ?? true) : null, left_out_count: leftOf(source), left_out_without_abstract: bareOf(source), left_out: leftOut[at]!.map((row) => ({ name: row.name, why: english.words.t(`leftWhy.${row.why}`) })), duplicates_merged: merged[at]!.map((row) => ({ name: row.name, same_as_paper_id: row.paper?.id ?? null })), added_at: since(source.addedAt), found: taken(source) + leftOf(source), after_duplicates: keptOf(source) })), papers: paperRows(out, papers).map((row, i) => ({ ...row, source_id: papers[i]!.source ?? null, settled_at: papers[i]!.settledAt ? iso(papers[i]!.settledAt!) : null })), // What its rule and criteria were from each moment on, the first first: a paper's result is read against the version in force at its settled_at. Changes made before these were kept are not in it. - history: versions.map((one) => ({ + history: versions.map((one, at) => ({ from: iso(one.at), // Null where nobody made the change by hand: who settles conflicts passed on when they left. by: one.by, - rule: ruleOut({ ...one.rule, each: one.rule.each === "all" ? "all" : `${one.rule.each}`, resolver: one.rule.resolver as string, models: one.rule.models ?? "vote" }, false), + rule: ruleOut({ ...one.rule, each: one.rule.each === "all" ? "all" : `${one.rule.each}`, resolver: one.rule.resolver as string, models: one.rule.models ?? "vote" }, [one.at, versions[at + 1]?.at ?? Infinity]), criteria: one.criteria.map((criterion) => criterionOut(criterion, [criterion.points.yes, criterion.points.no, criterion.points.unclear])), })), // The votes that were cast and show, each with the sentence a model named for its answers and how sure it was. diff --git a/components/screening/overview.tsx b/components/screening/overview.tsx index 0d11d4135..246deaf25 100644 --- a/components/screening/overview.tsx +++ b/components/screening/overview.tsx @@ -303,10 +303,11 @@ function Reviewers({ open, figures, now }: { open: Open; figures: Figures | unde // Moving someone's papers opens over the page as the screening's other dialogs do: a step in the history, with whose papers they are. const [moving, setMoving] = useOpenInAddress("moveFrom", null); const reviewers = inOrder(activeReviewers(screening), open.me); - const isPerson = new Set(screening.reviewers.filter((one) => one.kind === "person").map((one) => one.id)); + // The people listed here: agreement is of the reviewers on the screening, as the figure over them and the Agreement section say it. + const isPerson = new Set(reviewers.filter((one) => one.kind === "person").map((one) => one.id)); const rows: ReviewerRowData[] = reviewers.map((reviewer) => { const tally = reviewer.tally; - // A vote is compared with each person's on the same paper, and never with a model's: every pair of votes on a paper both voted on, and how many of them are the same. + // A vote is compared with each listed person's on the same paper, and never with a model's: every pair of votes on a paper both voted on, and how many of them are the same. const withPeople = (figures?.pairs ?? []).filter((pair) => (pair.a === reviewer.id && isPerson.has(pair.b)) || (pair.b === reviewer.id && isPerson.has(pair.a))); const compared = withPeople.reduce((sum, pair) => sum + pair.matrix.reduce((all, n) => all + n, 0), 0); // Where the share rests on one other person it opens the papers the two voted on; on more, the comparison pair by pair. @@ -561,6 +562,8 @@ function ReviewerRow({ open, row, onLeave, onMove }: { open: Open; row: Reviewer const { reviewer, assigned, done, split, agrees, agreesHref, known, compared, missed, included, left, perDay, idle } = row; const t = useTranslations("screening.overview"); const tp = useTranslations("screening.pieces"); + // What a model isn't given is said as Settings says it: one sentence for one fact. + const form = useTranslations("screening.form"); const words = useWords(); // The people there are to compare a vote with: none, where it is the only person or a model with no people beside it. const peopleOn = readersOf(screening).people.length; @@ -626,7 +629,7 @@ function ReviewerRow({ open, row, onLeave, onMove }: { open: Open; row: Reviewer ) : null} - {notGiven?.papers ?

{notGiven.why === "text" ? t("row.notGivenText", { count: notGiven.papers }) : t("row.notGivenLong", { count: notGiven.papers })}

: null} + {notGiven?.papers ?

{form("reviewers.pdfsMissed", { why: notGiven.why, count: notGiven.papers })}

: null} {/* How someone else voted is kept from a reviewer who still has papers to vote on: their own row, and how far each of the others is, say everything else. */} {reviewer.tally?.kept ? ( @@ -863,6 +866,8 @@ function Facts({ open }: { open: Open }) { const { screening, counts } = open; const t = useTranslations("screening.overview"); const tl = useTranslations("screening.list"); + // The balance is said as the form and Settings say it. + const form = useTranslations("screening.form"); const words = useWords(); const workspace = screening.workspace; const models = modelsOf(screening); @@ -936,7 +941,7 @@ function Facts({ open }: { open: Open }) {
- {/* Billing is its workspace's members' to open: anyone else reads the balance. */}{open.wallet === undefined ? null : {t("credits.leftIn", { credits: words.credits(left), workspace: workspace.name, own: String(screening.workspace.kind === "personal" && open.canChange) })}} + {/* Billing is its workspace's members' to open: anyone else reads the balance. */}{open.wallet === undefined ? null : {form("cost.inWorkspace", { credits: words.credits(left), workspace: workspace.name, own: String(screening.workspace.kind === "personal" && open.canChange) })}} {models.length ? {words.count("models", models.length)} : null} {/* The total counts what a model spent before it was taken off: said, so it adds up with the rows above. */} {offSpent >= 1 ? {t("credits.takenOff", { credits: words.credits(offSpent) })} : null} diff --git a/components/screening/papers.tsx b/components/screening/papers.tsx index a0837edf1..5df5a14d5 100644 --- a/components/screening/papers.tsx +++ b/components/screening/papers.tsx @@ -463,7 +463,9 @@ function Papers({ open, onExport }: { open: Open; onExport: (tab: ExportTab) => const settles = (reviewerId: string) => resolves(screening, reviewerId); // What the server has counted of the reviewer the table is narrowed to. The conflicts someone settled are not counted apart. const tally = reviewers.find((one) => one.id === who)?.tally; - const countVoted = (kind: Voted) => (!tally || kind === "settled" ? undefined : kind === "any" ? tally.cast : kind === "none" ? tally.waiting : tally[kind]); + // Their counts are of every paper of theirs: beside another narrowing (a source, a reason, a check, a result tab) they would promise more than the choice gives, so none is shown. + const narrowedElsewhere = from !== "all" || Boolean(reason) || added !== "all" || filter !== "all"; + const countVoted = (kind: Voted) => (!tally || kind === "settled" || narrowedElsewhere ? undefined : kind === "any" ? tally.cast : kind === "none" ? tally.waiting : tally[kind]); // The filters, in the row over the table and in a phone's sheet. const filters = (trigger: string) => ( <> @@ -473,7 +475,7 @@ function Papers({ open, onExport }: { open: Open; onExport: (tab: ExportTab) => value={from} onChange={(next) => go({ source: next === "all" ? null : next })} className={trigger} - choices={[{ value: "all", label: t("filter.all"), icon: , count: open.total }, ...screening.sources.map((source) => { const Icon = kindIcon(source.kind); return { value: source.id as string, label: source.name, icon: , count: keptOf(source) }; })]} + choices={[{ value: "all", label: t("filter.all"), icon: , count: open.total }, ...screening.sources.map((source) => { const Icon = kindIcon(source.kind); return { value: source.id as string, label: source.name, icon: , ...(who || reason || added !== "all" || filter !== "all" ? {} : { count: keptOf(source) }) }; })]} /> ) : null} {/* Any number of reviewers: with several, the table shows the papers all of them voted on. The menu stays open while they are picked. */} @@ -517,7 +519,7 @@ function Papers({ open, onExport }: { open: Open; onExport: (tab: ExportTab) => // Votes kept from the person looking are no list to open: each decision says why, as the column's menu does. ...DECISIONS.map((decision) => { const { icon: Icon, tone } = RESULT_STYLE[decision]; return { value: decision as Voted, label: words.decision(decision), icon: , tone, ...(tally?.kept ? { shut: words.t("hiddenWhileToDo") } : { count: countVoted(decision) }) }; }), { value: "none" as Voted, label: words.t("noVote.yet"), icon: , count: countVoted("none"), group: t("filter.noVote") }, - ...(countVoted("failed") ? [{ value: "failed" as Voted, label: words.t("noVote.failed"), icon: , tone: "destructive" as const, count: countVoted("failed"), group: t("filter.noVote") }] : []), + ...(tally?.failed || voted === "failed" ? [{ value: "failed" as Voted, label: words.t("noVote.failed"), icon: , tone: "destructive" as const, count: countVoted("failed"), group: t("filter.noVote") }] : []), // Papers settled by hand, where the rule can leave a paper split: under "first vote decides" the votes settle every paper, and the list would be of none. ...(settles(who) && splitsIn(screening, open.counts.conflict, open.invited) ? [{ value: "settled" as Voted, label: t("filter.settled"), icon: , tone: "info" as const, count: countVoted("settled"), group: t("filter.decisions") }] : []), ]} @@ -1158,7 +1160,7 @@ function PaperPanel({ paper, open, notes, setNotes, talk, onTalk, onClose, onSte {paper.withdrawn ? screen("shut.left") : screen("shut.finished", { canChange: String(open.canChange) })} ) : ( -

{/* What the buttons under it cast is the person's vote, never the settling: one they settled themselves says so at the foot, with its note and Reopen. */}{mine ? t("panel.changeVote") : state.final ? t("panel.settledWithoutYou") : t("panel.waitingForYou")}

+

{/* What the buttons under it cast is the person's vote, never the settling: one they settled themselves says so at the foot, with its note and Reopen. */}{mine ? t("panel.changeVote") : state.final && state.resolvedBy === open.me ? t("panel.yourVote") : state.final ? t("panel.settledWithoutYou") : t("panel.waitingForYou")}

{buttons("vote")} {/* Changing a vote can be let go, as the override can: the vote stands as it was. */} {/* Or taken back, and the paper waits for the person's vote again: what a selection's Undo does, for as long as the screening runs. */} diff --git a/components/screening/pieces.tsx b/components/screening/pieces.tsx index 7338fa467..a362d8aab 100644 --- a/components/screening/pieces.tsx +++ b/components/screening/pieces.tsx @@ -880,7 +880,7 @@ export function VoteFacts({ vote, failed = false, kept = false, settled = false, /** The reason a vote or a result excludes a paper, as a chip: the criterion it fails by its short name, with the whole question for whoever asks. The same chip wherever a reason shows. */ export function ReasonChip({ reason, criteria, className }: { reason: string; /** The criteria a reason can name, the ones taken off with them (./data.ts `reasonCriteria`). */ criteria: RetiredCriterion[]; className?: string }) { const words = useWords(); - return ; + return ; } /** To the paper before and the one after, with their keys: the same pair in Screen's bar and at the head of the Papers drawer. */ diff --git a/components/screening/screen.tsx b/components/screening/screen.tsx index ad51bc8e1..091bc0b00 100644 --- a/components/screening/screen.tsx +++ b/components/screening/screen.tsx @@ -489,6 +489,13 @@ function Screen({ open, castByMe, moved }: { open: Open; /** The person's votes, return void undo(); } if (event.metaKey || event.ctrlKey || event.altKey) return; + // While "another reason" is being written, a key is a letter of it, wherever the focus is: never a vote or a step. Escape still goes back. + if (writing) { + if (event.key === "Escape") { event.preventDefault(); setWriting(null); } + // Typed before the field took the focus: the field takes it, and the letter goes in. Tab, Enter and Space move about and press the form's buttons as anywhere. + else if (event.key.length === 1 && event.key !== " ") document.querySelector("[data-reason-note] textarea")?.focus(); + return; + } // While the last queue stands dimmed, no key reaches it: not a vote, an answer or a step. if (switching) return; const key = event.key.toLowerCase(); @@ -502,6 +509,7 @@ function Screen({ open, castByMe, moved }: { open: Open; /** The person's votes, bring(numbered); } else if ((key === "y" || key === "n" || key === "u") && toAnswer) { answerIt(toAnswer.key, key === "y" ? "yes" : key === "n" ? "no" : "unclear", true); + if (paper) keyed.current = { paper: paper.id, key: toAnswer.key }; // On to the next one still unanswered, so a paper's criteria are a run of keys. With a criterion picked, the next one is picked in its place. With none picked, none is: the keys then answer the first criterion still unanswered. const next = criteria.slice(criteria.indexOf(toAnswer) + 1).find((criterion) => given[criterion.key] === undefined); if (current) setLit(next && paper ? { paper: paper.id, key: next.key } : null); @@ -534,8 +542,9 @@ function Screen({ open, castByMe, moved }: { open: Open; /** The person's votes, const given: Record = paper && !resolving ? { ...mine?.answers, ...answers[paper.id] } : {}; const current = paper && lit?.paper === paper.id ? criteria.find((criterion) => criterion.key === lit.key) : undefined; - // The criterion Y, N and U answer: the one being looked at, or the first still unanswered. - const toAnswer = answerLook ? (current ?? criteria.find((criterion) => given[criterion.key] === undefined)) : undefined; + // The criterion Y, N and U answer: the one being looked at, or the first still unanswered, or, all of them answered, the one a key answered last, so a key can still change it. + const keyed = useRef<{ paper: string; key: string } | null>(null); + const toAnswer = answerLook ? (current ?? criteria.find((criterion) => given[criterion.key] === undefined) ?? (keyed.current?.paper === paper?.id ? criteria.find((criterion) => criterion.key === keyed.current?.key) : undefined)) : undefined; /** Looks at a criterion, or away from it when it is the one being looked at. The words marked for it open under the question and stand out in the abstract. The paper is never scrolled: whoever is reading the votes further down keeps their place. */ const light = (criterion: Criterion) => { if (!paper) return; diff --git a/convex/bench/screening-team.bench.ts b/convex/bench/screening-team.bench.ts index 6cd8a2575..039da67e4 100644 --- a/convex/bench/screening-team.bench.ts +++ b/convex/bench/screening-team.bench.ts @@ -51,7 +51,7 @@ describe("a screening with reviewers, read by its pages", () => { await t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); for (let from = 0; from < size; from += 200) { const step = Array.from({ length: Math.min(200, size - from) }, (_, n) => paper(from + n + 1, { title: `Paper ${from + n + 1}: ${text(100, from + n)}`, abstract: text(1_400, from + n) })); - await t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: step, read: step.length, ended: from + 200 >= size }); + await t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from, papers: step, read: step.length, ended: from + 200 >= size }); } const ids = (await papersOf(t, jobId)).map((one) => one._id as Id<"screeningResults">); // Ann votes on every paper, a third each way; Ben on the first half, agreeing on most, so some are in conflict. diff --git a/convex/limits/maxSizeScreening.test.ts b/convex/limits/maxSizeScreening.test.ts index bf0edc29f..08e50389d 100644 --- a/convex/limits/maxSizeScreening.test.ts +++ b/convex/limits/maxSizeScreening.test.ts @@ -36,7 +36,8 @@ describe("a screening with reviewers at the largest sizes the product allows", { // Ten people, each on every paper: its sources are read by the screening's own reading, a step at a time, and every paper dealt as it arrives. ({ jobId } = await started(made, PEOPLE, 0, { rule: { each: "all", settle: "all", blind: "after" } })); await runAll(made.t, tick); - }, 900_000); + // Fifty thousand places, each counted three ways (../screening/facets.ts): convex-test keeps the counts slower than a backend does. + }, 3_600_000); afterAll(() => { vi.clearAllTimers(); vi.useRealTimers(); @@ -85,9 +86,9 @@ describe("a step of papers that goes to many reviewers", { tags: ["size"] }, () const made = await team(["ann"]); await saved(made, 400); const { jobId } = await started(made, ["ann"], 0, { rule: { each: "all", settle: "all", blind: "after" } }); - // A hundred and twenty more people on it, each on every paper: a step of 200 papers is then 24,200 places, more rows than one transaction writes. + // Forty-four more people on it, the most a screening has, each on every paper: a step of 200 papers is then 9,000 places. await made.t.run(async (ctx) => { - for (let i = 0; i < 120; i++) { + for (let i = 0; i < 44; i++) { const userId = await ctx.db.insert("users", { clerkId: `guest_${i}`, email: `guest_${i}@test`, state: "active", createdAt: 1, updatedAt: 1 }); await ctx.db.insert("screeningReviewers", { jobId, kind: "person", userId, addedAt: 2 + i, addedBy: made.ids.ann!, dealt: 0 }); } @@ -95,7 +96,7 @@ describe("a step of papers that goes to many reviewers", { tags: ["size"] }, () await runAll(made.t, tick); const view = (await made.as.ann!.query(api.screening.view.get, { workspaceId: made.workspaceId, jobId }))!; expect(view).toMatchObject({ total: 400, forYou: 400 }); - expect(view.reviewers.map((one) => one.dealt)).toEqual(Array(121).fill(400)); + expect(view.reviewers.map((one) => one.dealt)).toEqual(Array(45).fill(400)); } finally { vi.clearAllTimers(); vi.useRealTimers(); @@ -125,4 +126,27 @@ describe("a step of papers that goes to many reviewers", { tags: ["size"] }, () vi.useRealTimers(); } }, 900_000); + + it("settles papers every one of the most reviewers voted on, and keeps the agreement of each pair of them", async () => { + vi.useFakeTimers(); + try { + // MAX_REVIEWERS people on every paper, each voting on all of them: settling adds to 990 pairs' agreement. + const people = ["ann", ...Array.from({ length: 44 }, (_, i) => `p${i}`)]; + const made = await team(people); + await saved(made, 10); + const { jobId } = await started(made, people, 0, { rule: { each: "all", settle: "all", blind: "after" } }); + await runAll(made.t, tick); + const { workspaceId } = made; + const papers = (await made.as.ann!.query(api.screening.paperViews.queue, { workspaceId, jobId, queue: "todo", ...page(10) })).page.map((one) => one.id); + for (const name of people) await made.as[name]!.mutation(api.screening.voting.voteMany, { workspaceId, jobId, paperIds: papers, decision: "include" }); + await runAll(made.t, tick); + expect((await made.as.ann!.query(api.screening.view.get, { workspaceId, jobId }))!.counts).toMatchObject({ include: 10, waiting: 0 }); + const { pairs } = (await made.as.ann!.query(api.screening.view.figures, { workspaceId, jobId, since: 0 }))!; + expect(pairs).toHaveLength(990); + expect(pairs.every((pair) => pair.matrix[0] === 10)).toBe(true); + } finally { + vi.clearAllTimers(); + vi.useRealTimers(); + } + }, 900_000); }); diff --git a/convex/schema.ts b/convex/schema.ts index c6201b7d4..35c91c276 100644 --- a/convex/schema.ts +++ b/convex/schema.ts @@ -1794,7 +1794,9 @@ export default defineSchema({ .index("by_source_and_pass", ["sourceId", "pass"]) .index("by_source_and_paperKey", ["sourceId", "paperKey"]) .index("by_into_and_source", ["into", "sourceId"]) - .index("by_job", ["jobId"]), + .index("by_job", ["jobId"]) + // A record merged into a paper still finds it by its own key (./screening/gathering.ts `twinOf`). + .index("by_job_and_paperKey", ["jobId", "paperKey"]), // What a source held that the screening doesn't take, each with why. screeningLeftOut: defineTable({ @@ -1828,6 +1830,8 @@ export default defineSchema({ added: v.number(), // Papers taken out with a source that it brought back: in the screening again, in the places they had. restored: v.optional(v.number()), + // Which reading of it is the live one: a check reopened reads anew, and a reader still out from before it ended writes nothing. + run: v.optional(v.number()), // Of what it found, the records left out (no abstract, nothing to read): neither added nor already in the screening. left: v.optional(v.number()), // The sources it couldn't read (each failed, with why, on its own row): a check that read none of them found nothing it can vouch for. diff --git a/convex/screening/audit.ts b/convex/screening/audit.ts index 86ee9b856..dfe54eb2f 100644 --- a/convex/screening/audit.ts +++ b/convex/screening/audit.ts @@ -56,17 +56,18 @@ export async function auditJob(ctx: QueryCtx, jobId: Id<"screeningJobs">) { const kept = progress.reviewers?.[reviewer._id]; if ((kept?.cast ?? 0) !== cast.length) problems.push(`${names.get(reviewer._id)}: counted ${kept?.cast ?? 0} votes, has ${cast.length}`); for (const decision of DECISIONS) if ((kept?.[decision] ?? 0) !== cast.filter((vote) => vote.decision === decision).length) problems.push(`${names.get(reviewer._id)}: counted ${kept?.[decision] ?? 0} ${decision}, has ${cast.filter((vote) => vote.decision === decision).length}`); - const holds = mine.filter((vote) => vote.status !== "discarded").length; + // A paper that left with its source is no longer one of its reviewers' papers. + const holds = mine.filter((vote) => vote.status !== "discarded" && liveIds.has(vote.resultId)).length; if (reviewer.dealt !== holds) problems.push(`${names.get(reviewer._id)}: said to hold ${reviewer.dealt} papers, holds ${holds}`); } for (const paper of live) { const on = votes.filter((vote) => vote.resultId === paper._id); const result: Result = paper.result ?? "waiting"; - const ballots: Ballot[] = on.map((vote) => ({ status: vote.status, decision: vote.decision, at: vote.at, reason: vote.reason })); + const ballots: Ballot[] = on.map((vote) => ({ status: vote.status, decision: vote.decision, at: vote.at, reason: vote.reason, kind: byId.get(vote.reviewerId)?.kind })); // A paper settled before the settings last changed keeps its result. Any other stands where its votes put it. const held = isFinal(result) && !paper.resolved && !paper.reopen && (paper.settledAt ?? 0) <= (job.heldAt ?? 0); - const voted = paper.resolved ? paper.resolved.decision : settle(rule.settle, ballots); + const voted = paper.resolved ? paper.resolved.decision : settle(rule.settle, ballots, rule.models); if (!held && result !== voted) problems.push(`${paper.title}: stands at ${result}, its votes say ${voted}`); const people = on.filter((vote) => byId.get(vote.reviewerId)?.kind === "person"); const places = people.filter((vote) => vote.status === "waiting" || vote.status === "cast"); @@ -125,6 +126,24 @@ export async function auditJob(ctx: QueryCtx, jobId: Id<"screeningJobs">) { if (JSON.stringify(counted) !== JSON.stringify(tally(on))) problems.push(`${names.get(reviewer._id)}: counted on ${JSON.stringify(counted)}, their papers ${JSON.stringify(tally(on))}`); } + // And the counts of two narrowings at once: each reviewer under each source and each check, and each source under each check. + const sourceIds = [...new Set(liveCards.flatMap((card) => (card.sourceId ? [card.sourceId] : [])))]; + const checkIds = [...new Set(liveCards.flatMap((card) => (card.checkId ? [card.checkId] : [])))]; + const ways = ["include", "maybe", "exclude", "cast", "waiting", "failed"] as const; + for (const reviewer of reviewers) { + const theirs = votes.filter((vote) => vote.reviewerId === reviewer._id && (vote.status === "waiting" || vote.status === "cast" || vote.status === "failed")).flatMap((vote) => { const card = cardOf.get(vote.resultId); return card && !card.withdrawn ? [card] : []; }); + for (const under of [...sourceIds.map((source) => ({ source })), ...checkIds.map((check) => ({ check }))]) { + const read = tally(theirs.filter((card) => ("source" in under ? card.sourceId === under.source : card.checkId === under.check)).map((card) => card.result)); + const counted = await tallyOfReviewer(ctx, reviewer._id, [...ways], under); + if (JSON.stringify(counted) !== JSON.stringify(read)) problems.push(`${names.get(reviewer._id)} under ${JSON.stringify(under)}: counted ${JSON.stringify(counted)}, their papers ${JSON.stringify(read)}`); + } + } + for (const sourceId of sourceIds) for (const checkId of checkIds) { + const read = tally(liveCards.filter((card) => card.sourceId === sourceId && card.checkId === checkId).map((card) => card.result)); + const counted = await tallyUnder(ctx, jobId, { source: sourceId, check: checkId }); + if (JSON.stringify(counted) !== JSON.stringify(read)) problems.push(`source ${sourceId} under check ${checkId}: counted ${JSON.stringify(counted)}, its papers ${JSON.stringify(read)}`); + } + const cast = Object.fromEntries(reviewers.map((one) => [names.get(one._id)!, progress.reviewers?.[one._id]?.cast ?? 0])); return { problems, cast, stands: Object.fromEntries(placed.map((paper) => [paper._id, paper.withdrawn ? "withdrawn" : (paper.result ?? "waiting")])) as Record }; } diff --git a/convex/screening/bookkeeping.ts b/convex/screening/bookkeeping.ts index 1e666cada..6ec2cf123 100644 --- a/convex/screening/bookkeeping.ts +++ b/convex/screening/bookkeeping.ts @@ -19,6 +19,8 @@ import type { MutationCtx, QueryCtx } from "../_generated/server"; import { internalMutation, internalQuery } from "../lib/functions"; import { upsertLibraryItem } from "../library/mutations"; import { findItem } from "../library/find"; +import { newCollection } from "../library/collections"; +import { readConvexErrorData } from "../lib/errors"; import { addCollectionMembership, removeCollectionMembership } from "../library/collectionMembership"; import { reviewersOf, VOTE_WRITES, votesOf } from "./dealing"; @@ -156,6 +158,26 @@ export async function saveQualified(ctx: MutationCtx, job: Doc<"screeningJobs">, await ctx.db.patch("screeningResults", result._id, { savedToLibrary: true, libraryItemId }); } +/** + * The screening with the collection its included papers go to made, where it is to be made: null where its workspace + * has no room for another, which the screening then says (`libraryWriteProblem: "full"`), its papers still settled. Made + * after it said so, the papers included meanwhile are saved to it too. + */ +export async function withCollection(ctx: MutationCtx, job: Doc<"screeningJobs">): Promise | null> { + if (!job.newCollection || job.targetCollectionId) return job; + const targetCollectionId = await newCollection(ctx, { userId: job.createdBy, workspaceId: job.workspaceId }, job.newCollection).catch((error: unknown) => { + if (!readConvexErrorData(error)) throw error; + return null; + }); + if (!targetCollectionId) { + if (job.libraryWriteProblem !== "full") await ctx.db.patch("screeningJobs", job._id, { libraryWriteProblem: "full" }); + return null; + } + await ctx.db.patch("screeningJobs", job._id, { targetCollectionId, newCollection: undefined, libraryWriteProblem: undefined }); + if (job.libraryWriteProblem === "full") await ctx.scheduler.runAfter(0, internal.screening.settings.shelveIncluded, { jobId: job._id, cursor: null }); + return { ...job, targetCollectionId, newCollection: undefined, libraryWriteProblem: undefined }; +} + /** * Puts a paper where its place in the job sends it, and says what that adds to the job's * count of papers saved and of papers removed. One that becomes included is saved, unless diff --git a/convex/screening/checks.ts b/convex/screening/checks.ts index 7635c9d5b..bbec37e91 100644 --- a/convex/screening/checks.ts +++ b/convex/screening/checks.ts @@ -25,9 +25,11 @@ export async function readOn(ctx: MutationCtx, job: Doc<"screeningJobs">, by: Id const check = await firstCheck(ctx, job._id); if (!check) return void (await startCheck(ctx, job, by)); if (check.state === "running") return; - await ctx.db.patch("screeningChecks", check._id, { state: "running", endedAt: undefined, beat: Date.now() }); + // Read anew as a run of its own: a reader still out from before it ended writes nothing. + const run = (check.run ?? 0) + 1; + await ctx.db.patch("screeningChecks", check._id, { state: "running", endedAt: undefined, beat: Date.now(), run }); await ctx.db.patch("screeningJobs", job._id, { reading: true }); - await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId: check._id }); + await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId: check._id, run }); await ctx.scheduler.runAfter(QUIET_MS, internal.screening.gathering.watch, { checkId: check._id, restarts: 0 }); } @@ -44,7 +46,7 @@ export async function startCheck(ctx: MutationCtx, job: Doc<"screeningJobs">, by const checkId = await ctx.db.insert("screeningChecks", { jobId: job._id, at: Date.now(), ...(by ? { by } : {}), ...(search ? { search } : {}), state: "running", from, found: 0, added: 0, beat: Date.now() }); // Papers are arriving while it reads, whichever look it is: a check asked for meanwhile joins it. await ctx.db.patch("screeningJobs", job._id, { reading: true }); - await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId }); + await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId, run: 0 }); await ctx.scheduler.runAfter(QUIET_MS, internal.screening.gathering.watch, { checkId, restarts: 0 }); return checkId; } diff --git a/convex/screening/doiRecords.ts b/convex/screening/doiRecords.ts index f3c820673..35cbfe68f 100644 --- a/convex/screening/doiRecords.ts +++ b/convex/screening/doiRecords.ts @@ -50,10 +50,11 @@ async function datacite(doi: string): Promise { } /** The records Crossref, then DataCite, hold for these DOIs, by DOI. A DOI neither holds isn't in what comes back. */ -export async function registered(dois: string[]): Promise> { +export async function registered(dois: string[], { strict = false }: { /** A registry that doesn't answer stops the reading, for a list of DOIs whose records these are. Looking up abstracts, it only finds none. */ strict?: boolean } = {}): Promise> { const found = new Map(); + const look = async (doi: string) => (await crossref(doi)) ?? (await datacite(doi)); for (let at = 0; at < dois.length; at += AT_ONCE) { - const records = await Promise.all(dois.slice(at, at + AT_ONCE).map(async (doi) => (await crossref(doi)) ?? (await datacite(doi)))); + const records = await Promise.all(dois.slice(at, at + AT_ONCE).map((doi) => (strict ? look(doi) : look(doi).catch(() => null)))); records.forEach((record, i) => { if (record) found.set(dois[at + i]!, record); }); } return found; diff --git a/convex/screening/effects.ts b/convex/screening/effects.ts index f456461ca..014423b60 100644 --- a/convex/screening/effects.ts +++ b/convex/screening/effects.ts @@ -251,7 +251,8 @@ export const preview = workspaceAction({ })); await Promise.all([ // Settled papers are read too where a source is taken out: theirs leave their people's counts. - ...(["waiting", "conflict", ...(change.recheck || base.discards || change.removeSources?.length ? SETTLED : [])] as const).map((result) => through(result, change.recheck === true, (read) => add(counted, loads, read))), + // A change that moves no paper and takes none out (sources added, a range, the words of a criterion) is counted with no read of the papers. + ...(base.decides || change.recheck || base.discards || change.removeSources?.length ? (["waiting", "conflict", ...(change.recheck || base.discards || change.removeSources?.length ? SETTLED : [])] as const) : []).map((result) => through(result, change.recheck === true, (read) => add(counted, loads, read))), // How many settled papers the change would move if they were checked again: what it holds back, and what asking for the check lets go. ...(base.decides && !change.recheck ? SETTLED : []).map((result) => through(result, true, (read) => { counted.again += read.counted.moves.reduce((sum, move) => sum + move.count, 0); })), ]); diff --git a/convex/screening/facets.ts b/convex/screening/facets.ts index 27b7ca687..5cb0c7e41 100644 --- a/convex/screening/facets.ts +++ b/convex/screening/facets.ts @@ -39,6 +39,12 @@ const checkOf = (jobId: Id<"screeningJobs">, checkId: Id<"screeningChecks">) => const reasonsOf = (jobId: Id<"screeningJobs">) => `${jobId}:reason`; const reviewerOf = (reviewerId: Id<"screeningReviewers">) => `${reviewerId}`; const castOf = (reviewerId: Id<"screeningReviewers">) => `${reviewerId}:at`; +// Two narrowings at once, as Papers offers them: a reviewer with a source, a check or a reason, and a source, a check and a reason with each other. +type Under = { source: Id<"screeningSources"> } | { check: Id<"screeningChecks"> }; +const reviewerUnder = (reviewerId: Id<"screeningReviewers">, under: Under) => ("source" in under ? `${reviewerId}:source:${under.source}` : `${reviewerId}:check:${under.check}`); +const reviewerReasons = (reviewerId: Id<"screeningReviewers">) => `${reviewerId}:reason`; +const sourceAndCheck = (jobId: Id<"screeningJobs">, sourceId: Id<"screeningSources">, checkId: Id<"screeningChecks">) => `${jobId}:source:${sourceId}:check:${checkId}`; +const reasonsUnder = (jobId: Id<"screeningJobs">, under: Under) => ("source" in under ? `${jobId}:source:${under.source}:reason` : `${jobId}:check:${under.check}:reason`); type Entry = { namespace: string; key: Key; id: string }; type Paper = Pick, "_id" | "jobId" | "place" | "withdrawn" | "result" | "sourceId" | "checkId" | "reason">; @@ -63,16 +69,23 @@ export function paperEntries(paper: Paper | null): Entry[] { ...(paper.sourceId ? [{ namespace: sourceOf(paper.jobId, paper.sourceId), key: result, id: paper._id }] : []), ...(paper.checkId ? [{ namespace: checkOf(paper.jobId, paper.checkId), key: result, id: paper._id }] : []), ...(result === "exclude" ? [{ namespace: reasonsOf(paper.jobId), key: paper.reason ?? NO_REASON, id: paper._id }] : []), + ...(paper.sourceId && paper.checkId ? [{ namespace: sourceAndCheck(paper.jobId, paper.sourceId, paper.checkId), key: result, id: paper._id }] : []), + ...(result === "exclude" && paper.sourceId ? [{ namespace: reasonsUnder(paper.jobId, { source: paper.sourceId }), key: paper.reason ?? NO_REASON, id: paper._id }] : []), + ...(result === "exclude" && paper.checkId ? [{ namespace: reasonsUnder(paper.jobId, { check: paper.checkId }), key: paper.reason ?? NO_REASON, id: paper._id }] : []), ]; } type Vote = Pick, "_id" | "reviewerId" | "status" | "decision" | "at">; /** A vote's entries: how its reviewer stands on its paper with where the paper stands, and, cast, when it was. */ -export function voteEntries(vote: Vote | null, paper: Pick | null): Entry[] { +export function voteEntries(vote: Vote | null, paper: Pick | null): Entry[] { if (!vote) return []; const way = vote.status === "cast" ? (vote.decision ?? "cast") : vote.status; + const on = way && counted(paper) ? `${way}|${resultOf(paper)}` : null; return [ - ...(way && counted(paper) ? [{ namespace: reviewerOf(vote.reviewerId), key: `${way}|${resultOf(paper)}`, id: vote._id }] : []), + ...(on ? [{ namespace: reviewerOf(vote.reviewerId), key: on, id: vote._id }] : []), + ...(on && paper!.sourceId ? [{ namespace: reviewerUnder(vote.reviewerId, { source: paper!.sourceId }), key: on, id: vote._id }] : []), + ...(on && paper!.checkId ? [{ namespace: reviewerUnder(vote.reviewerId, { check: paper!.checkId }), key: on, id: vote._id }] : []), + ...(on && resultOf(paper!) === "exclude" ? [{ namespace: reviewerReasons(vote.reviewerId), key: `${way}|${paper!.reason ?? NO_REASON}`, id: vote._id }] : []), ...(vote.status === "cast" && vote.at !== undefined ? [{ namespace: castOf(vote.reviewerId), key: vote.at, id: vote._id }] : []), ]; } @@ -103,8 +116,10 @@ export async function countPaperFacets(ctx: QueueingCtx, change: Change (counted(paper) ? `${resultOf(paper!)}|${paper!.sourceId}|${paper!.checkId}|${paper!.reason}` : null); + const before = standing(was); + const after = standing(now); // A paper just made has no votes yet: they are dealt after it, and counted by their own trigger. if (before === after || !was) return; const votes = await ctx.db.query("screeningVotes").withIndex("by_result", (q) => q.eq("resultId", change.id)).take(MAX_REVIEWERS); @@ -127,13 +142,13 @@ export const countEntries = (ctx: QueueingCtx, entries: Entry[]) => move(ctx, [] * completion ran with the triggers (../lib/functions.ts `withAppWrites`) left its vote counted as waiting, under where * its paper stood then, whatever the vote has done since, waited again included. */ -export const staleWaiting = (vote: Vote, paper: Pick | null): Entry[] => { +export const staleWaiting = (vote: Vote, paper: Pick | null): Entry[] => { const kept = voteEntries(vote, paper).find((entry) => entry.namespace === reviewerOf(vote.reviewerId))?.key; return RESULTS.map((result) => `waiting|${result}`).filter((key) => key !== kept).map((key) => ({ namespace: reviewerOf(vote.reviewerId), key, id: vote._id })); }; /** Takes out a vote's stale waiting entries, and counts it as it stands. */ -export async function recountVote(ctx: QueueingCtx, vote: Vote, paper: Pick | null) { +export async function recountVote(ctx: QueueingCtx, vote: Vote, paper: Pick | null) { await queueCounts(ctx, screeningCounts, staleWaiting(vote, paper).map((entry) => ({ type: "deleteIfExists" as const, ...entry }))); await countEntries(ctx, voteEntries(vote, paper)); } @@ -144,8 +159,8 @@ const countEach = (ctx: QueryCtx, namespace: string, keys: Key[]) => screeningCounts.countBatch(ctx, keys.map((key) => ({ namespace, bounds: { eq: key } })) as never, { stale: true }); /** How many of a screening's papers stand each way under one source, or one check. */ -export async function tallyUnder(ctx: QueryCtx, jobId: Id<"screeningJobs">, under: { source: Id<"screeningSources"> } | { check: Id<"screeningChecks"> }): Promise { - const counts = await countEach(ctx, "source" in under ? sourceOf(jobId, under.source) : checkOf(jobId, under.check), [...RESULTS]); +export async function tallyUnder(ctx: QueryCtx, jobId: Id<"screeningJobs">, under: Under | { source: Id<"screeningSources">; check: Id<"screeningChecks"> }): Promise { + const counts = await countEach(ctx, "source" in under && "check" in under ? sourceAndCheck(jobId, under.source, under.check) : "source" in under ? sourceOf(jobId, under.source) : checkOf(jobId, under.check), [...RESULTS]); return Object.fromEntries(RESULTS.map((result, at) => [result, counts[at]!])) as Tally; } @@ -160,10 +175,10 @@ export async function tallyForReason(ctx: QueryCtx, jobId: Id<"screeningJobs">, return { ...none(), exclude: (await excludedFor(ctx, jobId, [reason]))[reason] ?? 0 }; } -/** How many of the papers a reviewer stands one of `ways` on stand each way. */ -export async function tallyOfReviewer(ctx: QueryCtx, reviewerId: Id<"screeningReviewers">, ways: Way[]): Promise { +/** How many of the papers a reviewer stands one of `ways` on stand each way: all of them, or those one source or one check brought. */ +export async function tallyOfReviewer(ctx: QueryCtx, reviewerId: Id<"screeningReviewers">, ways: Way[], under?: Under): Promise { const keys = ways.flatMap((way) => RESULTS.map((result) => `${way}|${result}`)); - const counts = await countEach(ctx, reviewerOf(reviewerId), keys); + const counts = await countEach(ctx, under ? reviewerUnder(reviewerId, under) : reviewerOf(reviewerId), keys); const tally = none(); keys.forEach((key, at) => (tally[key.split("|")[1] as Result] += counts[at]!)); return tally; @@ -172,3 +187,15 @@ export async function tallyOfReviewer(ctx: QueryCtx, reviewerId: Id<"screeningRe /** How many votes a reviewer cast from `since` on. */ export const castSince = (ctx: QueryCtx, reviewerId: Id<"screeningReviewers">, since: number) => screeningCounts.count(ctx, { namespace: castOf(reviewerId), bounds: { lower: { key: since, inclusive: true } }, stale: true }); + +/** How many of the papers a reviewer stands one of `ways` on are excluded for `reason`. */ +export async function tallyOfReviewerForReason(ctx: QueryCtx, reviewerId: Id<"screeningReviewers">, ways: Way[], reason: string): Promise { + const counts = await countEach(ctx, reviewerReasons(reviewerId), ways.map((way) => `${way}|${reason}`)); + return { ...none(), exclude: counts.reduce((sum, n) => sum + n, 0) }; +} + +/** How many of the papers one source or one check brought are excluded for `reason`. */ +export async function tallyForReasonUnder(ctx: QueryCtx, jobId: Id<"screeningJobs">, reason: string, under: Under): Promise { + const [excluded] = await countEach(ctx, reasonsUnder(jobId, under), [reason]); + return { ...none(), exclude: excluded! }; +} diff --git a/convex/screening/files.test.ts b/convex/screening/files.test.ts index 7a768bfec..1cc029939 100644 --- a/convex/screening/files.test.ts +++ b/convex/screening/files.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { api, internal } from "../_generated/api"; import type { Id } from "../_generated/dataModel"; import { readAgain } from "./dealing"; -import { give, paper, started, team, type Team } from "./reviewers.test-support"; +import { give, paper, papersOf, started, team, type Team } from "./reviewers.test-support"; beforeEach(() => vi.useFakeTimers()); afterEach(() => vi.useRealTimers()); @@ -53,8 +53,11 @@ describe("what a source leaves out", () => { const leftOut = () => made.t.run((ctx) => ctx.db.query("screeningLeftOut").collect()); await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); // A Zotero library reads a paper filed in two collections twice: in one step, and again in a later one. - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: [bare, bare, paper(2)], read: 3, ended: false }); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: [bare], read: 1, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 0, papers: [bare, bare, paper(2)], read: 3, ended: false }); + // A second reader of that first step, set off by the watch while the first was slow, comes after it and takes nothing in: the source stays where the first left it. + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 0, papers: [paper(3)], read: 3, ended: false }); + expect(await sourceOf()).toMatchObject({ read: 3, taken: 1 }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 3, papers: [bare], read: 1, ended: true }); expect(await sourceOf()).toMatchObject({ taken: 1, left: 1, bare: 1 }); expect(await leftOut()).toHaveLength(1); @@ -63,10 +66,10 @@ describe("what a source leaves out", () => { await ctx.db.patch("screeningSources", sourceId, { ...readAgain((await ctx.db.get("screeningSources", sourceId))!), state: "reading" }); return checkId; }); - await made.t.mutation(internal.screening.gathering.fill, { checkId: await again(checkId), sourceId, pass: 1, papers: [bare, bare], read: 2, ended: false }); + await made.t.mutation(internal.screening.gathering.fill, { checkId: await again(checkId), sourceId, pass: 1, from: 0, papers: [bare, bare], read: 2, ended: false }); expect(await sourceOf()).toMatchObject({ left: 1, bare: 1 }); const later = await made.t.run((ctx) => ctx.db.insert("screeningChecks", { jobId, at: 2, state: "running", beat: 2, from: 1, found: 0, added: 0 })); - await made.t.mutation(internal.screening.gathering.fill, { checkId: await again(later), sourceId, pass: 2, papers: [bare, bare], read: 2, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId: await again(later), sourceId, pass: 2, from: 0, papers: [bare, bare], read: 2, ended: true }); expect(await sourceOf()).toMatchObject({ left: 1, bare: 1 }); expect(await leftOut()).toHaveLength(1); }); @@ -78,15 +81,15 @@ describe("what a source leaves out", () => { const sourceOf = () => made.t.run((ctx) => ctx.db.get("screeningSources", sourceId)); const listed = async () => (await made.as.ann!.query(api.screening.view.leftOut, { workspaceId: made.workspaceId, jobId, sourceId, paginationOpts: { cursor: null, numItems: 10 } })).page.map((row) => row.name).sort(); await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: [{ ...paper(1), abstract: undefined }, { ...paper(2), abstract: undefined }], read: 2, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 0, papers: [{ ...paper(1), abstract: undefined }, { ...paper(2), abstract: undefined }], read: 2, ended: true }); expect(await sourceOf()).toMatchObject({ left: 2, bare: 2 }); // A check reads it again, and has met the first paper and one that is new so far: the page still says two were left out, and lists the two it counted. await made.t.run(async (ctx) => ctx.db.patch("screeningSources", sourceId, { ...readAgain((await ctx.db.get("screeningSources", sourceId))!), state: "reading" })); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: [{ ...paper(1), abstract: undefined }, { ...paper(3), abstract: undefined }], read: 2, ended: false }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 0, papers: [{ ...paper(1), abstract: undefined }, { ...paper(3), abstract: undefined }], read: 2, ended: false }); expect(await sourceOf()).toMatchObject({ left: 2, bare: 2 }); expect(await listed()).toEqual(["Paper 1", "Paper 2"]); // The second paper is gone from the source: once the reading is whole, the count and the list are this reading's. - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: [], read: 0, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 2, papers: [], read: 0, ended: true }); expect(await sourceOf()).toMatchObject({ left: 2, bare: 2 }); expect((await sourceOf())!.next).toBeUndefined(); expect(await listed()).toEqual(["Paper 1", "Paper 3"]); @@ -101,7 +104,7 @@ describe("what a source leaves out", () => { await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); // Two records of one export with the same DOI, each under its own key, a third paper, and that third paper's record once more. A file hands each over as the record it is. const held = [paper(1, { doi: "10.1000/same" }), paper(2, { doi: "10.1000/same" }), paper(3), paper(3)].map((one, at) => ({ ...one, record: String(at + 1) })); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: held, read: 4, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 0, papers: held, read: 4, ended: true }); expect(await sourceOf()).toMatchObject({ read: 4, taken: 2, duplicates: 2, left: 0 }); expect(await made.t.run((ctx) => ctx.db.query("screeningLeftOut").collect())).toHaveLength(0); // Each repeat is named with the paper that stands for it, which this same file brought. @@ -110,25 +113,47 @@ describe("what a source leaves out", () => { // Its range is widened by two records, a new paper twice, so it is read again from its start, and a step that was cut short gives its records twice. Until the reading is whole, the count and the list are the first reading's. await made.t.run(async (ctx) => ctx.db.patch("screeningSources", sourceId, { ...readAgain((await ctx.db.get("screeningSources", sourceId))!), state: "reading" })); - for (const read of [0, 4]) await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: held, read, ended: false }); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: [{ ...paper(4), record: "5" }, { ...paper(4), record: "6" }], read: 2, ended: false }); + for (const read of [0, 4]) await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 0, papers: held, read, ended: false }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 4, papers: [{ ...paper(4), record: "5" }, { ...paper(4), record: "6" }], read: 2, ended: false }); expect(await sourceOf()).toMatchObject({ taken: 3, duplicates: 2 }); expect(await merged()).toEqual([["Paper 2", "Paper 1", sourceId], ["Paper 3", "Paper 3", sourceId]]); // Whole, it counts each repeat once: the two it met before, and the new one. - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: [], read: 0, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 6, papers: [], read: 0, ended: true }); expect(await sourceOf()).toMatchObject({ read: 6, taken: 3, duplicates: 3, left: 0 }); expect(await merged()).toEqual([["Paper 2", "Paper 1", sourceId], ["Paper 3", "Paper 3", sourceId], ["Paper 4", "Paper 4", sourceId]]); }); + it("finds a paper merged on its title by the DOI and the key its merged record brought, whatever title they come with later", async () => { + const made = await team(["ann"]); + const { jobId } = await started(made, ["ann"], 0, { sources: [{ set: { kind: "saved" }, name: "One" }, { set: { kind: "saved" }, name: "Two" }, { set: { kind: "saved" }, name: "Three" }] }); + const { checkId, sources } = await made.t.run(async (ctx) => ({ checkId: (await ctx.db.query("screeningChecks").withIndex("by_job", (q) => q.eq("jobId", jobId)).first())!._id, sources: (await ctx.db.query("screeningSources").withIndex("by_job", (q) => q.eq("jobId", jobId)).collect()).map((one) => one._id) })); + const [first, second, third] = sources as [Id<"screeningSources">, Id<"screeningSources">, Id<"screeningSources">]; + for (const sourceId of sources) await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); + // The first source has the paper with no DOI; the second has it with one, under another key, and is merged into it by its title and year. + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: first, pass: 0, from: 0, papers: [paper(1)], read: 1, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: second, pass: 0, from: 0, papers: [paper(2, { title: "Paper 1", doi: "10.1/one" })], read: 1, ended: true }); + // The third has it by that DOI under a title written another way, and by the second's key under another title. + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: third, pass: 0, from: 0, papers: [paper(3, { title: "Paper one, revised", doi: "10.1/one" }), paper(2, { title: "Yet another title" })], read: 2, ended: true }); + expect(await papersOf(made.t, jobId)).toHaveLength(1); + // The first source taken out, the paper stays as the second's record: met again by its key under any title, it is still the one paper. + await made.t.run((ctx) => ctx.db.patch("screeningSources", first, { removedAt: 3 })); + await made.t.mutation(internal.screening.settings.withdraw, { jobId, sourceId: first, cursor: null }); + const later = await made.t.run((ctx) => ctx.db.insert("screeningChecks", { jobId, at: 4, state: "running", beat: 4, from: 1, found: 0, added: 0 })); + await made.t.run(async (ctx) => ctx.db.patch("screeningSources", second, { ...readAgain((await ctx.db.get("screeningSources", second))!), state: "reading" })); + await made.t.mutation(internal.screening.gathering.fill, { checkId: later, sourceId: second, pass: 1, from: 0, papers: [paper(2, { title: "Paper 1, a title changed" })], read: 1, ended: true }); + expect(await papersOf(made.t, jobId)).toHaveLength(1); + expect(await made.t.run((ctx) => ctx.db.get("screeningSources", second))).toMatchObject({ taken: 1, duplicates: 0 }); + }); + it("names a record another source already brought, and counts one it meets twice in a reading once", async () => { const made = await team(["ann"]); const { jobId } = await started(made, ["ann"], 0, { sources: [{ set: { kind: "saved" }, name: "Saved papers" }, { set: { kind: "saved" }, name: "Saved again" }] }); const { checkId, sources } = await made.t.run(async (ctx) => ({ checkId: (await ctx.db.query("screeningChecks").withIndex("by_job", (q) => q.eq("jobId", jobId)).first())!._id, sources: (await ctx.db.query("screeningSources").withIndex("by_job", (q) => q.eq("jobId", jobId)).collect()).map((one) => one._id) })); const [first, second] = sources as [Id<"screeningSources">, Id<"screeningSources">]; for (const sourceId of sources) await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: first, pass: 0, papers: [paper(1)], read: 1, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: first, pass: 0, from: 0, papers: [paper(1)], read: 1, ended: true }); // The second source holds that paper too, and lists it under two of its folders, as a Zotero library does. - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: second, pass: 0, papers: [paper(1), paper(1), paper(2)], read: 3, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId: second, pass: 0, from: 0, papers: [paper(1), paper(1), paper(2)], read: 3, ended: true }); expect(await made.t.run((ctx) => ctx.db.get("screeningSources", second))).toMatchObject({ taken: 1, duplicates: 1 }); const merged = (await made.as.ann!.query(api.screening.view.merged, { workspaceId: made.workspaceId, jobId, sourceId: second, paginationOpts: { cursor: null, numItems: 10 } })).page; expect(merged.map((row) => [row.name, row.paper?.sourceId])).toEqual([["Paper 1", first]]); @@ -139,9 +164,9 @@ describe("what a source leaves out", () => { const { jobId } = await started(made, ["ann"], 0); const { checkId, sourceId } = await made.t.run(async (ctx) => ({ checkId: (await ctx.db.query("screeningChecks").withIndex("by_job", (q) => q.eq("jobId", jobId)).first())!._id, sourceId: (await ctx.db.query("screeningSources").withIndex("by_job", (q) => q.eq("jobId", jobId)).first())!._id })); await made.t.mutation(internal.screening.gathering.begin, { sourceId, pass: 0 }); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, papers: [paper(1)], read: 1, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 0, from: 0, papers: [paper(1)], read: 1, ended: true }); await made.t.run(async (ctx) => ctx.db.patch("screeningSources", sourceId, { ...readAgain((await ctx.db.get("screeningSources", sourceId))!), state: "reading" })); - await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, papers: [{ ...paper(1), abstract: undefined }, { ...paper(2), abstract: undefined }], read: 2, ended: true }); + await made.t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass: 1, from: 0, papers: [{ ...paper(1), abstract: undefined }, { ...paper(2), abstract: undefined }], read: 2, ended: true }); expect(await made.t.run((ctx) => ctx.db.get("screeningSources", sourceId))).toMatchObject({ taken: 1, left: 1, bare: 1 }); expect(await made.t.run((ctx) => ctx.db.query("screeningLeftOut").collect())).toMatchObject([{ name: "Paper 2", why: "abstract" }]); }); diff --git a/convex/screening/gathering.ts b/convex/screening/gathering.ts index 783892e71..e451fb837 100644 --- a/convex/screening/gathering.ts +++ b/convex/screening/gathering.ts @@ -55,12 +55,12 @@ const FAILURE_SHOWN = 600; const FILL_TRIES = 5; -type Reading = { gone?: true; full?: true; pass: number; places: number; sourceId: Id<"screeningSources">; part: number; set: SourceSet; first: number; last?: number; read: number; resume?: string; snapshot?: SearchSnapshot; state: "waiting" | "reading"; total?: number; userId: Id<"users">; workspaceId: Id<"workspaces"> }; +type Reading = { gone?: true; full?: true; pass: number; run: number; places: number; sourceId: Id<"screeningSources">; part: number; set: SourceSet; first: number; last?: number; read: number; resume?: string; snapshot?: SearchSnapshot; state: "waiting" | "reading"; total?: number; userId: Id<"users">; workspaceId: Id<"workspaces"> }; /** The next of a check's sources that still has papers to read, with where its reading stands. Null once every source is read, or the check has ended. */ export const next = internalQuery({ args: { checkId: v.id("screeningChecks") }, - returns: v.union(v.null(), v.object({ places: v.number(), sourceId: v.id("screeningSources"), part: v.number(), set: sourceSetValidator, first: v.number(), last: v.optional(v.number()), read: v.number(), resume: v.optional(v.string()), snapshot: v.optional(searchSnapshotValidator), state: v.union(v.literal("waiting"), v.literal("reading")), total: v.optional(v.number()), userId: v.id("users"), workspaceId: v.id("workspaces"), gone: v.optional(v.literal(true)), full: v.optional(v.literal(true)), pass: v.number() })), + returns: v.union(v.null(), v.object({ places: v.number(), sourceId: v.id("screeningSources"), part: v.number(), set: sourceSetValidator, first: v.number(), last: v.optional(v.number()), read: v.number(), resume: v.optional(v.string()), snapshot: v.optional(searchSnapshotValidator), state: v.union(v.literal("waiting"), v.literal("reading")), total: v.optional(v.number()), userId: v.id("users"), workspaceId: v.id("workspaces"), gone: v.optional(v.literal(true)), full: v.optional(v.literal(true)), pass: v.number(), run: v.number() })), handler: async (ctx, { checkId }): Promise => { const check = await ctx.db.get("screeningChecks", checkId); const job = check?.state === "running" ? await ctx.db.get("screeningJobs", check.jobId) : null; @@ -78,7 +78,7 @@ export const next = internalQuery({ const places = readersFor(job.rule?.each ?? "all", reviewers.filter(dealable).length) + reviewers.filter(readingModel).length; // A screening that holds as many papers as its plan takes asks no source for more: the source stops at once, and says why. const full = job.totalPapers - ((await progressRow(ctx, job._id))?.withdrawn ?? 0) >= (await papersLimit(ctx, job.workspaceId)); - return { ...(gone ? { gone: true as const } : {}), ...(full ? { full: true as const } : {}), pass: source.pass ?? 0, places, sourceId: source._id, part, set: source.set, first: source.first ?? 1, ...(source.last === undefined ? {} : { last: source.last }), read: source.read, ...(source.resume ? { resume: source.resume } : {}), ...(source.snapshot ? { snapshot: source.snapshot } : {}), state: source.state as "waiting" | "reading", ...(source.total === undefined ? {} : { total: source.total }), userId: source.addedBy, workspaceId: source.workspaceId ?? job.workspaceId }; + return { ...(gone ? { gone: true as const } : {}), ...(full ? { full: true as const } : {}), pass: source.pass ?? 0, run: check!.run ?? 0, places, sourceId: source._id, part, set: source.set, first: source.first ?? 1, ...(source.last === undefined ? {} : { last: source.last }), read: source.read, ...(source.resume ? { resume: source.resume } : {}), ...(source.snapshot ? { snapshot: source.snapshot } : {}), state: source.state as "waiting" | "reading", ...(source.total === undefined ? {} : { total: source.total }), userId: source.addedBy, workspaceId: source.workspaceId ?? job.workspaceId }; }, }); @@ -102,11 +102,12 @@ export const begin = internalMutation({ /** A source that couldn't be read is left as failed, with why in words for the person where it is something they can act on, and the check goes on to the next. The check counts it as one of its own it couldn't read. */ export const fail = internalMutation({ - args: { checkId: v.id("screeningChecks"), sourceId: v.id("screeningSources"), pass: v.number(), reason: v.optional(v.string()) }, + args: { checkId: v.id("screeningChecks"), sourceId: v.id("screeningSources"), pass: v.number(), run: v.optional(v.number()), reason: v.optional(v.string()) }, returns: v.null(), - handler: async (ctx, { checkId, sourceId, pass, reason }) => { - // A reading of the source from before it was changed fails nothing: the source is being read again. + handler: async (ctx, { checkId, sourceId, pass, run, reason }) => { + // A reading of the source from before it was changed fails nothing: the source is being read again. Nor does a reader the check has moved past. if (((await ctx.db.get("screeningSources", sourceId))?.pass ?? 0) !== pass) return null; + if (run !== undefined && ((await ctx.db.get("screeningChecks", checkId))?.run ?? 0) !== run) return null; await ctx.db.patch("screeningSources", sourceId, { state: "failed", failure: reason?.slice(0, FAILURE_SHOWN) }); const check = await ctx.db.get("screeningChecks", checkId); if (check && !check.unread?.includes(sourceId)) await ctx.db.patch("screeningChecks", checkId, { unread: [...(check.unread ?? []), sourceId].slice(-MAX_SOURCE_ROWS) }); @@ -119,30 +120,33 @@ export const fail = internalMutation({ * papers can't be read fails by itself, with why, and the others are still read. */ export const gather = internalAction({ - args: { checkId: v.id("screeningChecks") }, + args: { checkId: v.id("screeningChecks"), /** The reading of the check this reader is: one the check has moved past stops. */ run: v.optional(v.number()) }, returns: v.null(), - handler: async (ctx, { checkId }) => { + handler: async (ctx, { checkId, run: asked }) => { const started = Date.now(); + let run = asked; for (;;) { // Typed here: the generated API's types depend on this module, so inference would loop. const source: Reading | null = await ctx.runQuery(internal.screening.gathering.next, { checkId }); + run ??= source?.run; + if (source && source.run !== run) return; if (!source) return void (await ctx.runMutation(internal.screening.gathering.end, { checkId })); - if (Date.now() - started > READ_ACTION_MS) return void (await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId })); + if (Date.now() - started > READ_ACTION_MS) return void (await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId, run })); try { if (source.gone) throw createError("FORBIDDEN", "Whoever added this source is no longer in the workspace it is in. Add it again from this workspace."); if (source.full) { await ctx.runMutation(internal.screening.gathering.begin, { sourceId: source.sourceId, pass: source.pass }); - await ctx.runMutation(internal.screening.gathering.fill, { checkId, sourceId: source.sourceId, pass: source.pass, papers: [], read: 0, ended: false, full: true }); + await ctx.runMutation(internal.screening.gathering.fill, { checkId, sourceId: source.sourceId, pass: source.pass, run: source.run, from: source.read, papers: [], read: 0, ended: false, full: true }); continue; } // Its next PDFs are still being read for the first time: the check comes back for them, and is not taken for one gone quiet. if ((await step(ctx, checkId, source)) === "wait") { await ctx.runMutation(internal.screening.gathering.beat, { checkId }); - return void (await ctx.scheduler.runAfter(PDFS_WAIT_MS, internal.screening.gathering.gather, { checkId })); + return void (await ctx.scheduler.runAfter(PDFS_WAIT_MS, internal.screening.gathering.gather, { checkId, run })); } } catch (error) { console.error(`[screening] Source ${source.sourceId} couldn't be read`, error); - await ctx.runMutation(internal.screening.gathering.fail, { checkId, sourceId: source.sourceId, pass: source.pass, ...(readConvexErrorData(error)?.message ? { reason: readConvexErrorData(error)!.message } : {}) }); + await ctx.runMutation(internal.screening.gathering.fail, { checkId, sourceId: source.sourceId, pass: source.pass, run: source.run, ...(readConvexErrorData(error)?.message ? { reason: readConvexErrorData(error)!.message } : {}) }); } } }, @@ -163,6 +167,8 @@ export const beat = internalMutation({ async function step(ctx: ActionCtx, checkId: Id<"screeningChecks">, source: Reading): Promise<"wait" | void> { const { sourceId, set } = source; const reader = { userId: source.userId, workspaceId: source.workspaceId }; + // Where the source stands as this step hands its papers in: a step that hands them in parts (a Zotero library's) moves it on with each. + let handedTo = source.read; const give = async (papers: SearchPaper[], read: number, ended: boolean, resume?: string, leftOut?: LeftOut[]) => { // A paper that came with no abstract takes the one OpenAlex holds, and failing that the one registered under its DOI, whichever source brought it. A PDF's was asked for when the file was first read (./heldPdfs.ts): it comes with what that found. const bare = set.kind !== "pdf" && papers.some((paper) => !paper.abstract?.trim()); @@ -173,13 +179,14 @@ async function step(ctx: ActionCtx, checkId: Id<"screeningChecks">, source: Read for (let at = 0; at === 0 || at < ready.length; at += each) { const last = at + each >= ready.length; const goesOn = last ? resume : source.resume; - const args = { checkId, sourceId, pass: source.pass, papers: ready.slice(at, at + each), read: last ? read : 0, ended: ended && last, ...(goesOn ? { resume: goesOn } : {}), ...(at === 0 && leftOut?.length ? { leftOut } : {}) }; + const args = { checkId, sourceId, pass: source.pass, run: source.run, from: handedTo, papers: ready.slice(at, at + each), read: last ? read : 0, ended: ended && last, ...(goesOn ? { resume: goesOn } : {}), ...(at === 0 && leftOut?.length ? { leftOut } : {}) }; // A fill writes the reviewers' counts that voting and settling write too: one that loses to them every time Convex tries it is tried again here, with the papers it already has. for (let tries = 1; ; tries++) { try { await ctx.runMutation(internal.screening.gathering.fill, args); break; } catch (error) { if (readConvexErrorData(error) || tries >= FILL_TRIES) throw error; await new Promise((wait) => setTimeout(wait, 500 * 2 ** tries)); } } } + handedTo += read; }; const held = set.kind === "upload" || set.kind === "dois" || set.kind === "pdf" ? { ...source, set } : null; if (source.state === "waiting") { @@ -331,6 +338,10 @@ const SAME_TITLE = 5; async function twinOf(ctx: Pick, jobId: Id<"screeningJobs">, paper: { paperKey: string; doiKey?: string; titleKey: string }) { const byKey = await ctx.db.query("screeningResults").withIndex("by_job_paperKey", (q) => q.eq("jobId", jobId).eq("paperKey", paper.paperKey)).first(); if (byKey) return byKey; + // A record merged into a paper before is that paper, whatever title or DOI it comes with now. + const merged = await ctx.db.query("screeningMerged").withIndex("by_job_and_paperKey", (q) => q.eq("jobId", jobId).eq("paperKey", paper.paperKey)).first(); + const into = merged ? await ctx.db.get("screeningResults", merged.into) : null; + if (into) return into; const doiKey = paper.doiKey; const byDoi = doiKey ? await ctx.db.query("screeningResults").withIndex("by_job_and_doiKey", (q) => q.eq("jobId", jobId).eq("doiKey", doiKey)).first() : null; if (byDoi) return byDoi; @@ -348,12 +359,12 @@ async function twinOf(ctx: Pick, jobId: Id<"screeningJobs">, * reviewers. */ export const fill = internalMutation({ - args: { checkId: v.id("screeningChecks"), sourceId: v.id("screeningSources"), /** The reading of the source this step belongs to: one from before the source was changed takes nothing in. */ pass: v.number(), papers: v.array(screeningPaperInputValidator), read: v.number(), resume: v.optional(v.string()), ended: v.boolean(), /** The screening is full before this source gave anything: it stops as one that met the cap. */ full: v.optional(v.boolean()), /** What the source's own reading left out before any paper was made of it: a DOI nothing is known of, a file that doesn't open. */ leftOut: v.optional(v.array(v.object({ name: v.string(), why: leftOutWhyValidator, key: v.optional(v.string()) }))) }, + args: { checkId: v.id("screeningChecks"), sourceId: v.id("screeningSources"), /** The reading of the source this step belongs to: one from before the source was changed takes nothing in. */ pass: v.number(), /** The reading of the check: a reader it has moved past takes nothing in. */ run: v.optional(v.number()), /** How far into the source the step began: a second reader of the same step, set off by the watch, takes nothing in once the first has moved the source on. */ from: v.number(), papers: v.array(screeningPaperInputValidator), read: v.number(), resume: v.optional(v.string()), ended: v.boolean(), /** The screening is full before this source gave anything: it stops as one that met the cap. */ full: v.optional(v.boolean()), /** What the source's own reading left out before any paper was made of it: a DOI nothing is known of, a file that doesn't open. */ leftOut: v.optional(v.array(v.object({ name: v.string(), why: leftOutWhyValidator, key: v.optional(v.string()) }))) }, returns: v.null(), - handler: async (ctx, { checkId, sourceId, pass: reading, papers, read, resume, ended, full, leftOut }) => { + handler: async (ctx, { checkId, sourceId, pass: reading, run, from, papers, read, resume, ended, full, leftOut }) => { const [check, source] = await Promise.all([ctx.db.get("screeningChecks", checkId), ctx.db.get("screeningSources", sourceId)]); // A source taken out while its reading was out takes nothing in: its papers would arrive after it left. Nor does an earlier reading of one changed since. - const job = check?.state === "running" && source?.state === "reading" && source.removedAt === undefined && (source.pass ?? 0) === reading ? await ctx.db.get("screeningJobs", check.jobId) : null; + const job = check?.state === "running" && source?.state === "reading" && source.removedAt === undefined && (source.pass ?? 0) === reading && source.read === from && (run === undefined || (check.run ?? 0) === run) ? await ctx.db.get("screeningJobs", check.jobId) : null; if (!check || !source || !job) return null; const reviewers = await reviewersOf(ctx, job._id); const reads = await readsOf(ctx, reviewers); @@ -420,6 +431,8 @@ export const fill = internalMutation({ // A paper kept before its source named records is told by its paper alone. const own = twin.sourceId === sourceId && (paper.record === undefined || twin.record === undefined ? twin.paperKey === identity.paperKey : twin.record === paper.record); if (!own && (await merge(title, twin._id, named))) duplicates++; + // A paper merged on its title takes the DOI it lacked from the record merged into it: a later record with that DOI is the same paper. + if (!own && !twin.doiKey && keys.doiKey) await ctx.db.patch("screeningResults", twin._id, { doiKey: keys.doiKey, ...(twin.doi ? {} : { doi: paper.doi ?? paper.crossRefs?.doi }) }); // A paper already excluded, met in a collection read since, leaves it too where the screening takes excluded papers out: it would otherwise stay there for good, as its result never changes again. if (!own && job.prune && twin.result === "exclude" && !twin.withdrawn) { const source = await ctx.db.get("screeningSources", sourceId); @@ -495,7 +508,7 @@ export const end = internalMutation({ const check = await ctx.db.get("screeningChecks", checkId); if (check?.state !== "running") return null; // A source added while the last one was read waits for this look: the look reads on rather than end without it. - if ((await sourcesOf(ctx, check.jobId)).some((source) => source.removedAt === undefined && (source.state === "waiting" || source.state === "reading"))) return void (await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId })); + if ((await sourcesOf(ctx, check.jobId)).some((source) => source.removedAt === undefined && (source.state === "waiting" || source.state === "reading"))) return void (await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId, run: check.run ?? 0 })); const job = await ctx.db.get("screeningJobs", check.jobId); // The sources it couldn't read were counted on it as each failed (`fail`), so nothing reads it as a check that found nothing new. await ctx.db.patch("screeningChecks", checkId, { state: "done", endedAt: Date.now() }); @@ -528,7 +541,8 @@ export const watch = internalMutation({ await ctx.db.patch("screeningJobs", check.jobId, { reading: undefined, ...touched() }); return null; } - await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId }); + // A reader gone quiet is read on by another of the same run: a step takes its papers in only from where the source stands (`fill`), so two of them never take one page twice. + await ctx.scheduler.runAfter(0, internal.screening.gathering.gather, { checkId, run: check.run ?? 0 }); await ctx.scheduler.runAfter(QUIET_MS, internal.screening.gathering.watch, { checkId, restarts: restarts + 1 }); return null; }, diff --git a/convex/screening/held.ts b/convex/screening/held.ts index 0b21f6ebc..1e9bf6337 100644 --- a/convex/screening/held.ts +++ b/convex/screening/held.ts @@ -125,8 +125,8 @@ export async function withAbstracts(papers: SearchPaper[], spend: Spend | null): const sameWork = (one: string, other: string) => sameTitle(one, other) || (plainTitle(one) !== "" && plainTitle(one) === plainTitle(other)); for (let at = 0; at < bare.length; at += DOIS_A_REQUEST) { const ids = bare.slice(at, at + DOIS_A_REQUEST).map((paper) => paper.paper.slice("openalex:".length)); - // OpenAlex not answering is no reason to leave a paper out for having no abstract: the reading stops with why, and the source is read again once it answers. - const { works } = await readSearchPage({ filter: `openalex:${ids.join("|")}`, sort: BY_DOI_SORT, source: "openalex" }, { page: 1, size: DOIS_A_REQUEST, select: "id,title,abstract_inverted_index" }, spend!).catch((error) => { console.error("[screening] OpenAlex couldn't be asked for abstracts", error); throw createError("EXTERNAL_SERVICE_ERROR", "OpenAlex didn't answer while abstracts were looked up. Read this source again in a few minutes."); }); + // A paper OpenAlex can't be asked about now is screened, or left out, as it came: a source isn't stopped for one lookup. + const { works } = await readSearchPage({ filter: `openalex:${ids.join("|")}`, sort: BY_DOI_SORT, source: "openalex" }, { page: 1, size: DOIS_A_REQUEST, select: "id,title,abstract_inverted_index" }, spend!).catch((error) => { console.error("[screening] OpenAlex couldn't be asked for abstracts", error); return { works: [] as Work[] }; }); for (const work of works) { const paper = work.id ? toPaper(work) : null; if (!paper?.abstract) continue; @@ -253,7 +253,8 @@ export async function handedPapers(ctx: ActionCtx, source: Held, from: number, t const dois = (await textOf(ctx, set.file)).split("\n").filter(Boolean).slice(from - 1, to); const found = await byDois(dois, spend); // A DOI the index has no record of is the paper Crossref or DataCite registered under it, where one did. - const elsewhere = await registered(dois.filter((doi) => !found.has(doi))); + // A list of DOIs is its records: one a registry didn't answer for isn't "no record of it", so the reading stops and is read again. + const elsewhere = await registered(dois.filter((doi) => !found.has(doi)), { strict: true }); const papers = dois.flatMap((doi, at): SearchPaper[] => { const [known, record] = [found.get(doi), elsewhere.get(doi)]; const paper = known ?? (record && fromRecord(record, paperKey({ source: "upload", file: `${set.file}.${from + at}` }))); diff --git a/convex/screening/moving.ts b/convex/screening/moving.ts index cde275574..74f1b46cb 100644 --- a/convex/screening/moving.ts +++ b/convex/screening/moving.ts @@ -13,7 +13,8 @@ import { give, holds, roomFor } from "../sharing/access"; import { grantOf, itemGuestsOf, type Shared } from "../sharing/items"; import { workspaceName } from "../workspaces/personal"; import { progressRow } from "./bookkeeping"; -import { dealable, keepVersion, modelsFree, readingModel, reviewersOf, sourcesOf, waitingOf } from "./dealing"; +import { dealable, keepVersion, modelsFree, papersOf, readingModel, reviewersOf, sourcesOf, waitingOf } from "./dealing"; +import { papersLimit } from "./slots"; /** Why a screening can't move yet, in words for whoever asked, or null. */ export async function heldHere(ctx: Pick, job: Doc<"screeningJobs">): Promise { @@ -35,11 +36,21 @@ export async function heldHere(ctx: Pick, job: Doc<"screeningJob */ export async function carry(ctx: MutationCtx, by: Id<"users">, job: Doc<"screeningJobs">, to: Id<"workspaces">) { const shared: Shared<"screening"> = { kind: "screening", id: job._id, workspaceId: to, name: job.name ?? "Screening", size: job.totalPapers, createdBy: job.createdBy }; + // A screening goes only where its plan takes as many papers as it holds. + const papersThere = await papersLimit(ctx, to); + const holding = papersOf(job, await progressRow(ctx, job._id)); + if (holding > papersThere) throw createError("VALIDATION_ERROR", `This screening holds ${holding.toLocaleString("en")} papers. ${await workspaceName(ctx, to)}'s plan takes up to ${papersThere.toLocaleString("en")} in one screening.`); const people = (await reviewersOf(ctx, job._id)).filter(dealable); + // Its reviewers outside the workspace it goes to vote as its guests: one who had it as a member of the workspace it leaves and could only look at it as a guest is now let vote, and one with no place on it is given one. A guest made one who looks stays one: being taken off follows the change. + const from: Shared<"screening"> = { ...shared, workspaceId: job.workspaceId }; const outside: Doc<"users">[] = []; + const looking: Doc<"users">[] = []; for (const one of people) { const person = await ctx.db.get("users", one.userId!); - if (person && !(await holds(ctx, shared, person)) && !(await grantOf(ctx, job._id, person._id))) outside.push(person); + if (!person || (await holds(ctx, shared, person))) continue; + const grant = await grantOf(ctx, job._id, person._id); + if (!grant) outside.push(person); + else if (grant.role !== "editor" && (await holds(ctx, from, person))) looking.push(person); } const most = await roomFor(ctx, shared); if (most !== undefined && outside.length && (await countOf(ctx, itemGuestsOf(job._id))) + outside.length > most) { @@ -63,5 +74,5 @@ export async function carry(ctx: MutationCtx, by: Id<"users">, job: Doc<"screeni } await ctx.db.patch("screenings", job.screeningId, { workspaceId: to }); for (const source of await sourcesOf(ctx, job._id)) if (source.workspaceId === undefined) await ctx.db.patch("screeningSources", source._id, { workspaceId: job.workspaceId }); - for (const person of outside) await give(ctx, shared, person, "editor", { userId: by, author: "user" }); + for (const person of [...outside, ...looking]) await give(ctx, shared, person, "editor", { userId: by, author: "user" }); } diff --git a/convex/screening/paperViews.ts b/convex/screening/paperViews.ts index 6c8464d2d..a66669a49 100644 --- a/convex/screening/paperViews.ts +++ b/convex/screening/paperViews.ts @@ -18,7 +18,7 @@ import { askedOf, reviewersOf, seesPaper, viewId, votesOf } from "./dealing"; import { placeOf } from "./settling"; import { decisionValidator, paperResultValidator, paperViewValidator, voteViewValidator } from "./validators"; import { keepsVotesNow } from "./view"; -import { tallyForReason, tallyOfReviewer, tallyUnder } from "./facets"; +import { tallyForReason, tallyForReasonUnder, tallyOfReviewer, tallyOfReviewerForReason, tallyUnder, type Way } from "./facets"; type Paper = Doc<"screeningResults">; type Vote = Doc<"screeningVotes">; @@ -135,7 +135,7 @@ const readCursor = (cursor: string | null): [string | null, number] => { } }; /** Papers a page of a search reads at once to find the ones its filters keep. */ -const SEARCH_SCAN = 200; +const SEARCH_SCAN = 100; /** * A page of papers found by their words, kept to what `keep` says, so a page is never cut before its filters are @@ -181,6 +181,8 @@ export const pdf = workspaceQuery({ /** Papers one count looks through: more than any plan gives one screening. Past it, no count is given. */ const COUNTED = 8_192; +/** A reviewer's votes one count reads whole, notes and answers with them: 1,500 of the longest fit in what one query reads. ponytail: past it a count narrowed three ways with a reviewer is not given; facets for those triples if people miss it. */ +const VOTES_COUNTED = 1_500; /** * How many of a screening's papers stand each way under what the Papers page is narrowed to: a source, a check, a @@ -208,16 +210,22 @@ export const counts = workspaceQuery({ // Which way someone else voted is kept from a reviewer who still has papers to vote on (./view.ts `keepsVotes`): so is how many they voted each way. const others = row && voted && voted !== "none" && voted !== "failed" && row._id !== looking.reviewer?._id; if (others && !showsEarly(looking.job.rule!, row.kind) && (await keepsVotesNow(ctx, looking.job, looking.reviewer, looking.reviewers.values()))) return null; - // Narrowed one way, the counts are kept already (./facets.ts): a few counted reads, whatever the screening's size. + // Narrowed one way or two, the counts are kept already (./facets.ts): a few counted reads, whatever the screening's size. const narrowed = [source, check, reason, row].filter(Boolean).length; + const ways: Way[] = voted === "none" ? ["waiting"] : voted === "failed" ? ["failed"] : voted ? [voted] : ["include", "maybe", "exclude", "cast"]; if (narrowed === 1) { - if (row) return await tallyOfReviewer(ctx, row._id, voted === "none" ? ["waiting"] : voted === "failed" ? ["failed"] : voted ? [voted] : ["include", "maybe", "exclude", "cast"]); + if (row) return await tallyOfReviewer(ctx, row._id, ways); if (source) return await tallyUnder(ctx, jobId, { source }); if (check) return await tallyUnder(ctx, jobId, { check }); return await tallyForReason(ctx, jobId, reason!); } - // Narrowed two ways at once, the cards of the narrower way are counted one by one: a reviewer's votes, or the papers of one reason, check or source. - // ponytail: a namespace per pair of narrowings would count those too, if they come to be used on screenings past a few thousand papers. + if (narrowed === 2) { + if (row && reason) return await tallyOfReviewerForReason(ctx, row._id, ways, reason); + if (row) return await tallyOfReviewer(ctx, row._id, ways, source ? { source } : { check: check! }); + if (source && check) return await tallyUnder(ctx, jobId, { source, check }); + return await tallyForReasonUnder(ctx, jobId, reason!, source ? { source } : { check: check! }); + } + // Narrowed three ways at once, the cards of the narrower way are counted one by one: a reviewer's votes, or the papers of one reason, check or source. const keeps = (card: Doc<"screeningCards">) => !card.withdrawn && (!source || card.sourceId === source) && (!check || card.checkId === check) && (!reason || (card.result === "exclude" && (card.reason ?? NO_REASON) === reason)); const tally = { include: 0, maybe: 0, exclude: 0, conflict: 0, waiting: 0 }; if (!row) { @@ -232,8 +240,8 @@ export const counts = workspaceQuery({ : voted ? votes.withIndex("by_reviewer_and_status_and_decision_and_at", (q) => q.eq("reviewerId", row._id).eq("status", "cast").eq("decision", voted)) : votes.withIndex("by_reviewer_and_status_and_at", (q) => q.eq("reviewerId", row._id).eq("status", "cast")) - ).take(COUNTED + 1); - if (theirs.length > COUNTED) return null; + ).take(VOTES_COUNTED + 1); + if (theirs.length > VOTES_COUNTED) return null; // Their votes are matched to the cards of the other narrowing, read in one range: one read a vote would pass a transaction's index ranges on a large screening. const cards = await cardsOf(ctx, jobId, { reason, check, source }).take(COUNTED + 1); if (cards.length > COUNTED) return null; diff --git a/convex/screening/reviewers.test-support.ts b/convex/screening/reviewers.test-support.ts index f22a5586d..d594798f5 100644 --- a/convex/screening/reviewers.test-support.ts +++ b/convex/screening/reviewers.test-support.ts @@ -58,13 +58,13 @@ type T = Team["t"]; /** Gives a screening's source `at` these records in one step, and returns the papers it took, in their order. */ export async function give(t: T, jobId: Id<"screeningJobs">, at: number, papers: FunctionArgs["papers"]) { - const { checkId, sourceId, pass } = await t.run(async (ctx) => { + const { checkId, sourceId, pass, from } = await t.run(async (ctx) => { const check = (await ctx.db.query("screeningChecks").withIndex("by_job", (q) => q.eq("jobId", jobId)).order("desc").first())!; const source = (await ctx.db.query("screeningSources").withIndex("by_job", (q) => q.eq("jobId", jobId)).collect())[at]!; - return { checkId: check._id, sourceId: source._id, pass: source.pass ?? 0 }; + return { checkId: check._id, sourceId: source._id, pass: source.pass ?? 0, from: source.read }; }); await t.mutation(internal.screening.gathering.begin, { sourceId, pass }); - await t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass, papers, read: papers.length, ended: true }); + await t.mutation(internal.screening.gathering.fill, { checkId, sourceId, pass, from, papers, read: papers.length, ended: true }); return { checkId, sourceId, papers: await papersOf(t, jobId) }; } diff --git a/convex/screening/sending.ts b/convex/screening/sending.ts index 894e39ecb..da77a7526 100644 --- a/convex/screening/sending.ts +++ b/convex/screening/sending.ts @@ -14,11 +14,11 @@ import { rateLimit } from "../lib/rateLimit"; import { workspaceAction } from "../lib/userActions"; import { standingOn } from "./access"; import { nameOf } from "./dealing"; +import { EMAILED_FILES_BYTES } from "../../lib/export"; import { screeningPath } from "../../lib/screening/links"; -/** Files one email carries at most, how large they may be together, and how long a note may be. The files go to a Node action whole, and its arguments take 5 MiB at most: 4 MiB of files leaves room for the rest. */ +/** Files one email carries at most, and how long a note may be. How large they may be together is `EMAILED_FILES_BYTES`. */ const FILES_MAX = 6; -const BYTES_MAX = 4 * 1024 * 1024; const NOTE_MAX = 2_000; const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const fileValidator = v.object({ name: v.string(), type: v.string(), body: v.string(), base64: v.optional(v.boolean()) }); @@ -39,7 +39,7 @@ export const sendFiles = workspaceAction({ if (!files.length || files.length > FILES_MAX) throw createError("VALIDATION_ERROR", `Send 1 to ${FILES_MAX} files at a time.`); if (!files.every(exported)) throw createError("VALIDATION_ERROR", "Only Export's own files can be sent."); if ((note?.length ?? 0) > NOTE_MAX) throw createError("VALIDATION_ERROR", "That note is too long."); - if (new TextEncoder().encode(JSON.stringify(files)).length > BYTES_MAX) throw createError("VALIDATION_ERROR", "These files are too large for one email. Send fewer, or download them."); + if (new TextEncoder().encode(JSON.stringify(files)).length > EMAILED_FILES_BYTES) throw createError("VALIDATION_ERROR", "These files are too large for one email. Send fewer, or download them."); const about: { name: string; path: string; by: string; replyTo?: string; opens: boolean } = await ctx.runQuery(internal.screening.sending.about, { jobId, userId: actor.userId, workspaceId: actor.workspaceId, to: address }); await ctx.runMutation(internal.screening.sending.spend, { userId: actor.userId }); await ctx.runAction(internal.screening.filesMail.send, { ...about, to: address, files: files.map((one) => ({ name: shortName(one.name), type: one.type, body: one.body, ...(one.base64 ? { base64: true } : {}) })), ...(note?.trim() ? { note: note.trim() } : {}) }); diff --git a/convex/screening/settings.ts b/convex/screening/settings.ts index 5515627f6..6ffe2440e 100644 --- a/convex/screening/settings.ts +++ b/convex/screening/settings.ts @@ -11,13 +11,13 @@ import type { MutationCtx, QueryCtx } from "../_generated/server"; import { queueLibraryWrite } from "../evidenceLibraries/writes"; import { createError } from "../lib/errors"; import { internalMutation } from "../lib/functions"; -import { newCollection, screeningDestination } from "../library/collections"; +import { screeningDestination } from "../library/collections"; import { workspaceAction, workspaceMutation } from "../lib/userActions"; import { actorIn } from "../workspaces/actor"; import { type Criterion } from "../../lib/screening/rules"; import { requireMember } from "./access"; import { pdfBand } from "../../lib/pricing/estimate"; -import { bookkeepLater, progressRow, saveQualified } from "./bookkeeping"; +import { bookkeepLater, progressRow, saveQualified, withCollection } from "./bookkeeping"; import { keepVersion, keeperOf, readAgain, dealable, papersAStep, settlerFor, modelRow, nameOf, readingModel, reviewersOf, sourcesOf, touched, votesOf } from "./dealing"; import { startCheck } from "./checks"; import { check } from "./living"; @@ -96,10 +96,14 @@ export async function planned(ctx: Pick, job: Doc<"screeningJobs dropped: before.filter((criterion) => !keys.has(criterion.key)), stricter: criteria.filter((criterion) => criterion.must && was.get(criterion.key)?.must === false).map((criterion) => criterion.key), moves, - // Whether the change touches what decides where a paper stands: its papers as well. - decides: moves || Boolean(change.addSources?.length || change.removeSources?.length || change.ranges?.length), + // Whether the change touches what decides where a paper stands. Sources added, taken out or read to another range move no paper it has: their papers come and go on their own. + decides: moves, + // Whether the papers' points or stars change: every settled paper is scored again, keeping its result. A criterion's words changed alone change neither. + rescores: JSON.stringify(stars) !== JSON.stringify(job.stars ?? []) || pointsOf(criteria) !== pointsOf(before), }; } +/** What each answer to each criterion is worth. */ +const pointsOf = (criteria: Criterion[]) => JSON.stringify(criteria.map((criterion) => [criterion.key, criterion.points])); /** What of its criteria decides a model's vote: which there are, and which a paper must meet. */ const settling = (criteria: Criterion[]) => criteria.map((criterion) => `${criterion.key}:${criterion.must}`).join(); @@ -180,7 +184,7 @@ async function apply(ctx: MutationCtx, actor: { userId: Id<"users">; workspaceId ...(change.criteria || change.stars ? { criteria: plan.criteria, stars: plan.stars, ...legacyOf(plan.criteria, plan.stars), retiredCriteria: retiredOf(job, plan.criteria) } : {}), rule: plan.rule, ...(change.living !== undefined ? { living: change.living ? { every: change.living, next: now + EVERY_MS[change.living] } : undefined } : {}), - ...(change.saveTo ? { targetCollectionId: undefined, newCollection: undefined, unsaved: undefined, libraryDestination, ...(later ? { newCollection: later } : await screeningDestination(ctx, writer, change.saveTo)) } : {}), + ...(change.saveTo ? { targetCollectionId: undefined, newCollection: undefined, unsaved: undefined, libraryDestination, libraryWriteProblem: undefined, libraryPruneProblem: undefined, ...(later ? { newCollection: later } : await screeningDestination(ctx, writer, change.saveTo)) } : {}), ...(change.prune !== undefined ? { prune: change.prune ? (true as const) : undefined } : {}), ...(plan.decides && !change.recheck ? { heldAt: now } : {}), ...touched(now), @@ -222,8 +226,8 @@ async function apply(ctx: MutationCtx, actor: { userId: Id<"users">; workspaceId if (!checks && reads && !(await ctx.db.query("screeningChecks").withIndex("by_job_and_state", (q) => q.eq("jobId", jobId).eq("state", "running")).first())) await startCheck(ctx, saved, actor.userId); // What follows on its papers, a step at a time: the open ones are settled again under the new settings, with people's votes marked where a criterion became a must-have and the models reading again where one was added. - if (plan.decides || change.recheck || plan.added.length || plan.stricter.length || change.stars) { - await ctx.scheduler.runAfter(0, internal.screening.settings.follow, { jobId, cursor: null, results: change.recheck ? ["waiting", "conflict", "include", "maybe", "exclude"] : change.stars && !plan.decides ? ["include", "maybe", "exclude", "waiting", "conflict"] : ["waiting", "conflict"], recheck: change.recheck === true, stricter: plan.stricter, reread: plan.added.length > 0 }); + if (plan.decides || change.recheck || plan.added.length || plan.stricter.length || plan.rescores) { + await ctx.scheduler.runAfter(0, internal.screening.settings.follow, { jobId, cursor: null, results: change.recheck || plan.rescores ? ["waiting", "conflict", "include", "maybe", "exclude"] : ["waiting", "conflict"], recheck: change.recheck === true, stricter: plan.stricter, reread: plan.added.length > 0 }); } // The papers it has included go to a collection it is newly sent to. if (change.saveTo && change.saveTo.kind !== "none") await ctx.scheduler.runAfter(0, internal.screening.settings.shelveIncluded, { jobId, cursor: null }); @@ -299,7 +303,9 @@ export const withdraw = internalMutation({ const { row } = kept; // Read again for each paper: an earlier paper of this step may have moved to the same source. const keeper = (await ctx.db.get("screeningSources", kept.source._id))!; - await ctx.db.patch("screeningResults", paper._id, { sourceId: keeper._id, record: undefined, doneAt: ctx.db.vars.commitTs }); + // It is the record that source holds from now on, by which a later reading of it, or a record merged before, finds it (./gathering.ts `twinOf`): a file's by its place in the file, any other's by its key. + const fromFile = keeper.set.kind === "upload" || keeper.set.kind === "dois" || keeper.set.kind === "pdf"; + await ctx.db.patch("screeningResults", paper._id, { sourceId: keeper._id, ...(fromFile ? { record: row.paperKey } : { record: undefined, ...(row.paperKey ? { paperKey: row.paperKey } : {}) }), doneAt: ctx.db.vars.commitTs }); const filed = !paper.abstract && paper.file; const band = pdfBand(paper.pages ?? 0); const spread = { ...keeper.fileSpread }; @@ -341,10 +347,11 @@ export const shelveIncluded = internalMutation({ let job = await ctx.db.get("screeningJobs", jobId); if (!job || (job.unsaved && !job.libraryDestination)) return null; const page = await ctx.db.query("screeningResults").withIndex("by_job_and_result", (q) => q.eq("jobId", jobId).eq("result", "include")).paginate({ cursor, numItems: SHELVE }); - if (page.page.length && job.newCollection && !job.targetCollectionId) { - const targetCollectionId = await newCollection(ctx, { userId: job.createdBy, workspaceId: job.workspaceId }, job.newCollection); - await ctx.db.patch("screeningJobs", jobId, { targetCollectionId, newCollection: undefined }); - job = { ...job, targetCollectionId, newCollection: undefined }; + if (page.page.length) { + // With no room for its collection, the screening says so and its included papers wait in it. + const made = await withCollection(ctx, job); + if (!made) return null; + job = made; } for (const paper of page.page) { if (!job.unsaved) await saveQualified(ctx, job, paper); diff --git a/convex/screening/settling.test.ts b/convex/screening/settling.test.ts index 8d8e52356..583af4a97 100644 --- a/convex/screening/settling.test.ts +++ b/convex/screening/settling.test.ts @@ -438,6 +438,33 @@ describe("a record a screening read from a file", () => { expect((await standingOf(made.t, jobId)).papers[0]).toMatchObject({ result: "include" }); expect(await made.t.run((ctx) => ctx.db.query("libraryItems").collect())).toMatchObject([{ title: "A report no index knows", abstract: "What the report found." }]); }); + + it("is saved with those included while the workspace had no room for the collection, once there is room", async () => { + const made = await team(["ann"]); + const { jobId } = await started(made, ["ann"], 0, { rule: { each: 1, settle: "all", blind: "after" }, saveTo: { kind: "new", name: "Included in Tutoring" } }); + // The plan takes one collection, and the workspace has it. + const room = (count: number) => made.t.run(async (ctx) => { + const counted = await ctx.db.query("collectionCounts").withIndex("by_workspace", (q) => q.eq("workspaceId", made.workspaceId)).unique(); + if (counted) await ctx.db.patch("collectionCounts", counted._id, { count }); + else await ctx.db.insert("collectionCounts", { workspaceId: made.workspaceId, count }); + const account = await ctx.db.query("billingAccounts").withIndex("by_workspace", (q) => q.eq("workspaceId", made.workspaceId)).unique(); + await ctx.db.patch("billingAccounts", account!._id, { limits: { collections: 1 } }); + }); + await room(1); + const { papers } = await give(made.t, jobId, 0, [{ paper: "upload:export.0", title: "First included", abstract: "One." }, { paper: "upload:export.1", title: "Second included", abstract: "Two." }]); + const vote = voter(made, jobId); + await vote("ann", papers[0]!._id, "include"); + await runAll(made.t, vi.runAllTimers); + expect(await made.t.run((ctx) => ctx.db.get("screeningJobs", jobId))).toMatchObject({ libraryWriteProblem: "full" }); + // A collection deleted, the next paper included makes the screening's, and the one included before goes in it too. + await room(0); + await vote("ann", papers[1]!._id, "include"); + await runAll(made.t, vi.runAllTimers); + const job = (await made.t.run((ctx) => ctx.db.get("screeningJobs", jobId)))!; + expect(job.libraryWriteProblem).toBeUndefined(); + const held = await made.t.run((ctx) => ctx.db.query("libraryItemCollections").withIndex("by_collection_item", (q) => q.eq("collectionId", job.targetCollectionId!)).collect()); + expect(held).toHaveLength(2); + }); }); describe("the queue every screening's papers are settled from", () => { diff --git a/convex/screening/settling.ts b/convex/screening/settling.ts index 78447dfe2..476e12e53 100644 --- a/convex/screening/settling.ts +++ b/convex/screening/settling.ts @@ -12,8 +12,7 @@ import type { Doc, Id } from "../_generated/dataModel"; import type { MutationCtx } from "../_generated/server"; import { cellOf, decidingVotes, DECISIONS, emptyMatrix, isFinal, NO_REASON, reasonOf, scoreOf, type Answer, type Decision, type Result } from "../../lib/screening/rules"; -import { newCollection } from "../library/collections"; -import { progressOf, shelve, withMoved } from "./bookkeeping"; +import { progressOf, shelve, withCollection, withMoved } from "./bookkeeping"; import { ballotOf, project, type Place, type Projected } from "../../lib/screening/project"; import { countDealt, invitedTo, modelRow, personRow, readsOf, reviewersOf, teamFor, teamOf, votesOf } from "./dealing"; import { conflictsWait } from "./notices"; @@ -122,12 +121,14 @@ export async function settlePapers(ctx: MutationCtx, made: Doc<"screeningJobs">, const reads = await readsOf(ctx, reviewers); for (const paper of papers) { let votes = await votesOf(ctx, paper._id); - const ballots = () => votes.map(ballot); const was: Result = paper.result ?? "waiting"; // Held through a change of settings: settled by then, and nobody has voted on it or asked for it to be checked again since. // One brought over from before screenings had reviewers stands as it stood then, until someone votes on it or its settled papers are checked again. const carried = paper.kept && !paper.resolved && !paper.reopen ? paper.kept : undefined; const held = carried !== undefined || (isFinal(paper.result) && !paper.resolved && !paper.reopen && (paper.settledAt ?? 0) <= (job.heldAt ?? 0)); + // A held paper's votes stand as they were counted: a model's vote is not worked out again under criteria the paper wasn't settled under. + const read = (vote: Vote) => (held && vote.status === "cast" && vote.decision ? { ...ballot(vote), decision: vote.decision, reason: vote.reason } : ballot(vote)); + const ballots = () => votes.map(read); // Where it stands and who is on it is one sum, the same one a change's preview runs (lib/screening/project.ts): this applies it to the rows. const places = votes.map((vote) => placeOf(vote, byId.get(vote.reviewerId))); // One whose source was taken out and that another source brought back (./gathering.ts `fill`): its open places were let go, and are given out again. @@ -175,7 +176,7 @@ export async function settlePapers(ctx: MutationCtx, made: Doc<"screeningJobs">, const after: typeof before = []; let changed = false; for (const vote of votes) { - const cast = ballot(vote); + const cast = read(vote); // What a model's reading cost is kept counted whatever becomes of its paper: the credits went. const counted: Counted = paper.withdrawn ? { status: "discarded", ...(vote.credits ? { credits: vote.credits } : {}) } : { status: vote.status, ...(cast.decision ? { decision: cast.decision } : {}), ...(vote.credits ? { credits: vote.credits } : {}) }; if (!paper.withdrawn && cast.status === "cast" && cast.decision) after.push({ id: vote.reviewerId, decision: cast.decision }); @@ -222,12 +223,18 @@ export async function settlePapers(ctx: MutationCtx, made: Doc<"screeningJobs">, if ((now === "include") !== (was === "include") || (now === "exclude") !== (was === "exclude")) { const sets = await setsOf(ctx, paper); // The collection its included papers go to is made with the first of them. + // A workspace with no room for another collection still has its papers settled: they are kept in the screening, and the page says why they aren't saved. + // With no room for it, the paper is saved once there is (`withCollection`): it still goes back to a collection it was taken out of. + let saving = job; if (now === "include" && job.newCollection && !job.targetCollectionId) { - const targetCollectionId = await newCollection(ctx, { userId: job.createdBy, workspaceId: job.workspaceId }, job.newCollection); - await ctx.db.patch("screeningJobs", job._id, { targetCollectionId, newCollection: undefined }); - job = { ...job, targetCollectionId, newCollection: undefined }; + const made = await withCollection(ctx, job); + if (made) job = saving = made; + else { + job = { ...job, libraryWriteProblem: "full" }; + saving = { ...job, unsaved: true }; + } } - const to = await shelve(ctx, job, { ...paper, ...patch }, { becameIncluded: now === "include" && was !== "include", left: now === "exclude" && was !== "exclude" }, sets); + const to = await shelve(ctx, saving, { ...paper, ...patch }, { becameIncluded: now === "include" && was !== "include", left: now === "exclude" && was !== "exclude" }, sets); moved.saved += to.saved; moved.removed += to.removed; } diff --git a/convex/screening/validators.ts b/convex/screening/validators.ts index c0c3fd6b1..64af6bad2 100644 --- a/convex/screening/validators.ts +++ b/convex/screening/validators.ts @@ -132,7 +132,8 @@ export const libraryDestinationValidator = v.object({ libraryId: v.id("evidenceL /** How a paper went to a library collection: put in, or not, because the library holds no record of it. */ export const libraryWriteValidator = v.union(v.literal("added"), v.literal("missing")); /** Why a job's writes to a library collection stopped: the person can no longer change it, it's gone, or the library didn't answer. */ -export const libraryWriteProblemValidator = v.union(v.literal("role"), v.literal("notFound"), v.literal("unreadable")); +// `full`: the workspace has as many collections as its plan allows, so the collection its included papers go to can't be made. +export const libraryWriteProblemValidator = v.union(v.literal("role"), v.literal("notFound"), v.literal("unreadable"), v.literal("full")); /** * Where a screened paper landed: included at the job's minimum score; unclear when its @@ -314,8 +315,12 @@ export const reviewerCountsValidator = v.object({ cast: v.number(), include: v.n // ── What the pages read (./view.ts, ./paperViews.ts) ───────────────────────────────────────────── // Each list here is one its writes keep within a cap: a screening's reviewers and sources, and a paper's votes. -/** The most reviewers a screening has, people who left it included, and the most sources it has ever had. */ -export const MAX_REVIEWERS = 200; +/** + * The most reviewers a screening has, people who left it included, and the most sources it has ever had. Under + * "everyone votes" a paper settled adds to the agreement of every pair of its voters, one read and one write each in + * the step that settles it: 45 reviewers make 990 pairs, well within the 4,096 ranges a transaction reads, and a list one read returns. + */ +export const MAX_REVIEWERS = 45; export const MAX_SOURCE_ROWS = 100; /** The sources one check couldn't read. */ export const unreadSourcesValidator = capped(v.optional(v.array(v.id("screeningSources"))), MAX_SOURCE_ROWS); @@ -467,8 +472,8 @@ export const paperViewValidator = v.object({ asked: v.optional(v.boolean()), }); -/** Pairs of reviewers whose agreement one read holds. */ -export const PAIRS_MAX = 400; +/** Pairs of reviewers whose agreement one read holds: every pair a screening can have. */ +export const PAIRS_MAX = (MAX_REVIEWERS * (MAX_REVIEWERS - 1)) / 2; /** The figures a screening's overview and its files are drawn from (./view.ts `figures`). */ export const figuresValidator = v.object({ // Its excluded papers by the reason, and its included ones by the source that brought each. diff --git a/convex/screening/view.ts b/convex/screening/view.ts index 82141e94f..61b043588 100644 --- a/convex/screening/view.ts +++ b/convex/screening/view.ts @@ -482,7 +482,7 @@ export const getAction = defineUserQuery({ destination: job.libraryDestination ? { kind: "community" as const, name: job.libraryDestination.name, libraryId: job.libraryDestination.libraryId, libraryCollection: job.libraryDestination.collection, prune: job.prune === true, ...(job.libraryWriteProblem ? { problem: job.libraryWriteProblem } : {}), ...(job.libraryPruneProblem ? { pruneProblem: job.libraryPruneProblem } : {}) } : job.newCollection - ? { kind: "new" as const, name: job.newCollection, prune: job.prune === true } + ? { kind: "new" as const, name: job.newCollection, prune: job.prune === true, ...(job.libraryWriteProblem === "full" ? { problem: "full" as const } : {}) } : collection ? { kind: "collection" as const, name: collection.name, collectionId: collection._id, prune: job.prune === true } : { kind: "none" as const, prune: job.prune === true }, diff --git a/convex/screening/voting.ts b/convex/screening/voting.ts index c7f9ff23e..c120a63a3 100644 --- a/convex/screening/voting.ts +++ b/convex/screening/voting.ts @@ -8,7 +8,7 @@ import type { Doc, Id } from "../_generated/dataModel"; import type { MutationCtx } from "../_generated/server"; import { createError } from "../lib/errors"; import { workspaceMutation } from "../lib/userActions"; -import { NAMED_REASONS, type Answer } from "../../lib/screening/rules"; +import { givenReason, NAMED_REASONS, NO_REASON, type Answer } from "../../lib/screening/rules"; import { requireReviewer, standingOn } from "./access"; import { bookkeepLater } from "./bookkeeping"; import { countDealt, personRow, votesOf } from "./dealing"; @@ -23,8 +23,8 @@ async function paperOf(ctx: Pick, jobId: Id<"screeningJobs">, return paper; } -/** Stamps a paper a person voted on or settled, for the bookkeeping worker: their vote or decision lets go of a result held through a change of settings. */ -const stamp = (ctx: MutationCtx, resultId: Id<"screeningResults">) => ctx.db.patch("screeningResults", resultId, { doneAt: ctx.db.vars.commitTs, reopen: "vote" }); +/** Stamps a paper a person voted on or settled, for the bookkeeping worker: their vote or decision lets go of a result held through a change of settings. Answers given to a vote already cast only have it scored again: the vote is the one counted, and holds nothing open. */ +const stamp = (ctx: MutationCtx, resultId: Id<"screeningResults">, release = true) => ctx.db.patch("screeningResults", resultId, { doneAt: ctx.db.vars.commitTs, ...(release ? { reopen: "vote" as const } : {}) }); /** A reason to exclude is one of the screening's criteria, or one of the others. Undo puts back a vote as it was cast, by a criterion taken off since too. */ function requireReason(job: Doc<"screeningJobs">, reason: string | undefined, undoing: boolean) { @@ -43,6 +43,8 @@ async function cast(ctx: MutationCtx, { job, reviewer }: { job: Doc<"screeningJo const mine = (await votesOf(ctx, paperId)).find((vote) => vote.reviewerId === reviewer._id); if (onlyWaiting && mine?.status !== "waiting") return false; if (onlyAt !== undefined && (mine?.status !== "cast" || (mine.edited ?? mine.at) !== onlyAt)) return false; + // Answers to a vote taken back meanwhile, in another tab, cast nothing. + if (answersOnly && mine?.status !== "cast") return false; if (decision === null) { // Taken back: the place is theirs again to vote from. One with no vote to take back changes nothing. if (mine?.status !== "cast") return false; @@ -53,16 +55,20 @@ async function cast(ctx: MutationCtx, { job, reviewer }: { job: Doc<"screeningJo const known = new Set([...(job.criteria ?? []), ...(onlyAt !== undefined ? (job.retiredCriteria ?? []) : [])].map((criterion) => criterion.key)); // A criterion given as the reason to exclude is one the voter says is not met, so its answer is No wherever the vote was cast from. const given = { ...Object.fromEntries(Object.entries(answers ?? {}).filter(([key]) => known.has(key))), ...(decision === "exclude" && reason && known.has(reason) ? { [reason]: "no" as const } : {}) }; - // Answers joining a vote already cast leave it the vote it was: cast when it was, which "first vote decides" reads, and asked for again if it was. - const kept = answersOnly && mine?.status === "cast" ? mine : undefined; - const vote = { status: "cast" as const, decision, answers: given, reason: decision === "exclude" ? reason : undefined, note: note?.trim() || undefined, at: kept?.at ?? Date.now(), edited: kept ? Date.now() : undefined, flagged: kept?.flagged }; + // Answers joining a vote already cast change only the answers: it stays the vote it was, whatever another tab saved meanwhile, cast when it was, which + // "first vote decides" reads, and asked for again if it was. An exclusion that rested on a criterion answered otherwise now rests on what the answers say. + const kept = answersOnly ? mine : undefined; + const keptReason = kept?.decision === "exclude" ? ((kept.reason && (job.criteria ?? []).some((one) => one.key === kept.reason) && given[kept.reason] !== "no") || kept.reason === NO_REASON ? (givenReason(job.criteria ?? [], given, kept.note ?? "") ?? NO_REASON) : kept.reason) : undefined; + const vote = kept + ? { status: "cast" as const, decision: kept.decision!, answers: given, reason: keptReason, note: kept.note, at: kept.at ?? Date.now(), edited: Date.now(), flagged: kept.flagged } + : { status: "cast" as const, decision, answers: given, reason: decision === "exclude" ? reason : undefined, note: note?.trim() || undefined, at: Date.now(), edited: undefined, flagged: undefined }; if (mine) await ctx.db.patch("screeningVotes", mine._id, vote); else { // A reviewer who votes on a paper that wasn't given to them is on it from then on. await ctx.db.insert("screeningVotes", { ...personRow(job, paper, reviewer), ...vote }); await countDealt(ctx, new Map([[reviewer._id, 1]])); } - await stamp(ctx, paperId); + await stamp(ctx, paperId, !kept); return vote.edited ?? vote.at; } diff --git a/convex/sharing/invitations.ts b/convex/sharing/invitations.ts index 7fe3647e2..3c32c918c 100644 --- a/convex/sharing/invitations.ts +++ b/convex/sharing/invitations.ts @@ -247,13 +247,15 @@ export const getAction = defineUserQuery({ if (!shared) return null; // One that was accepted shows only to whoever holds the place it gave, or has it by having joined its workspace since. const reader = await ctx.db.get("users", userId); - const state = invitation.state === "pending" ? ("pending" as const) : invitation.state === "accepted" && ((await grantOf(ctx, shared.id, userId)) || (reader && (await holds(ctx, shared, reader)))) ? ("accepted" as const) : null; + const grant = invitation.state === "accepted" ? await grantOf(ctx, shared.id, userId) : null; + const state = invitation.state === "pending" ? ("pending" as const) : invitation.state === "accepted" && (grant || (reader && (await holds(ctx, shared, reader)))) ? ("accepted" as const) : null; if (!state) return null; // The link alone says nothing of the item: it may have been passed on. The address it was sent to does. if (state === "pending" && !(reader && addressesOf(reader).includes(invitation.email))) return { state: "other" as const }; const [inviter, from] = await Promise.all([ctx.db.get("users", invitation.invitedBy), workspaceFrom(ctx, shared.workspaceId)]); return { - kind: shared.kind, id: shared.id, name: shared.name, role: invitation.role, + // One accepted says what its guest may do now, which whoever shared it may have changed since. + kind: shared.kind, id: shared.id, name: shared.name, role: grant?.role ?? invitation.role, // Someone whose account is gone is named by the workspace they shared it from, as the list of invitations names them. by: { name: inviter ? personName(inviter) || inviter.email : from.name, ...(inviter?.avatarUrl ? { imageUrl: inviter.avatarUrl } : {}) }, from, ...(shared.size === undefined ? {} : { size: shared.size }), state, ...(await screeningFacts(ctx, shared)), diff --git a/lib/export.ts b/lib/export.ts index 6b043956e..a1cc40c35 100644 --- a/lib/export.ts +++ b/lib/export.ts @@ -131,6 +131,9 @@ export function exportFilename(name: string, format: ExportFormat, part = 1) { /** How long an export's link waits for its next part to be fetched; the browser fetches it at once. */ export const EXPORT_LINK_MS = 2 * 60_000; + +/** How large the files one email sends may be together (convex/screening/sending.ts): a Node action takes them whole, and its arguments take 5 MiB at most. */ +export const EMAILED_FILES_BYTES = 4 * 1024 * 1024; /** How long the page waits for a part it opened to start before it calls the export failed. */ const PART_START_MS = 30_000; diff --git a/lib/screening/rules.test.ts b/lib/screening/rules.test.ts index b670eaa4f..0a94d66e0 100644 --- a/lib/screening/rules.test.ts +++ b/lib/screening/rules.test.ts @@ -78,6 +78,8 @@ describe("the reason an excluded paper is counted under", () => { expect(reasonOf(ballots)).toBe("b"); expect(reasonOf(ballots, "other")).toBe("other"); expect(reasonOf([cast("include")])).toBeUndefined(); + // One person gave a reason and one gave none: the reason given stands. + expect(reasonOf([cast("exclude", 1, "unstated"), cast("exclude", 2, "c1")])).toBe("c1"); }); it("under the first vote decides, is the reason of the person's vote that settled it, not an earlier model's", () => { diff --git a/lib/screening/rules.ts b/lib/screening/rules.ts index ff8b484d9..3b0b50920 100644 --- a/lib/screening/rules.ts +++ b/lib/screening/rules.ts @@ -124,7 +124,8 @@ export function settle(rule: Rule["settle"], ballots: Ballot[], models: Rule["mo export function reasonOf(ballots: Ballot[], settled?: string): string | undefined { if (settled) return settled; const given = ballots.flatMap((one) => (one.status === "cast" && one.decision === "exclude" && one.reason ? [one.reason] : [])); - return [...new Set(given)].sort((a, b) => given.filter((reason) => reason === b).length - given.filter((reason) => reason === a).length)[0]; + // As often given as another, a stated reason goes before no reason given. + return [...new Set(given)].sort((a, b) => given.filter((reason) => reason === b).length - given.filter((reason) => reason === a).length || Number(a === NO_REASON) - Number(b === NO_REASON))[0]; } /** A paper's points and stars, from the answer most of its reviewers gave to each criterion. `stars` holds the points each star starts at. */ diff --git a/messages/af.json b/messages/af.json index b895b2eaf..644320105 100644 --- a/messages/af.json +++ b/messages/af.json @@ -7964,7 +7964,8 @@ "says": "Die lêers is soos jy hulle sou aflaai, sonder wat vir jou versteek is. Antwoorde kom na jou.", "send": "Stuur", "sent": "{count, plural, one {Lêer na {to} gestuur} other {# lêers na {to} gestuur}}", - "failed": "Die lêers is nie gestuur nie" + "failed": "Die lêers is nie gestuur nie", + "tooLarge": "{count, plural, one {Hierdie lêer is te groot vir 'n e-pos. Laai dit eerder af.} other {Hierdie lêers is saam te groot vir een e-pos. Stuur minder, of laai hulle af.}}" }, "title": "Voer uit", "description": "Die artikels, elke stem, die PRISMA-diagram, ’n metodeparagraaf en die hele rekord", @@ -8824,7 +8825,7 @@ "onItsWay": "Die PDF is op pad", "cantShow": "Hierdie PDF kan nie hier gewys word nie. Maak dit in ’n nuwe oortjie oop." }, - "perPaper": "{credits, plural, one {# krediet} other {# krediete}} per artikel", + "perPaper": "Omtrent {credits, plural, one {# krediet} other {# krediete}} per artikel", "pickerCost": "Krediete per artikel" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, one {# artikel wat dit nie kon lees nie} other {# artikels wat dit nie kon lees nie}}", "unread": "{count, number} kon nie gelees word nie", "unreadSays": "{count, plural, one {Dit kon nie hierdie artikel lees nie, so dit het geen sê daaroor nie.} other {Dit kon nie hierdie # artikels lees nie, so dit het geen sê daaroor nie.}}", - "notGivenText": "{count, plural, one {Kry nie die PDF nie, want dit lees net teks} other {Kry nie die # PDF’e nie, want dit lees net teks}}", - "notGivenLong": "{count, plural, one {Kry nie # PDF wat langer is as wat dit op een slag lees nie} other {Kry nie # PDF’e wat langer is as wat dit op een slag lees nie}}", "voted": "{decision, select, include {{count, number} het Sluit in gestem} maybe {{count, number} het Miskien gestem} other {{count, number} het Sluit uit gestem}}", "noOtherPerson": "Geen ander persoon om mee te vergelyk nie", "aloneOnPapers": "Geen ander persoon lees hul artikels nie", @@ -8973,7 +8972,7 @@ "startedIt": "het dit {ago} begin" }, "included": { - "problem": "{why, select, role {Jy kan {name} nou net bekyk, so ingesluite artikels {adding, select, true {word nie daarby gevoeg nie} other {word nie daaruit gehaal nie}}} notFound {{name} is nie meer in die Evidence Community nie, so ingesluite artikels {adding, select, true {word nie daarby gevoeg nie} other {word nie daaruit gehaal nie}}} other {Die Evidence Community het nie geantwoord nie, so sommige ingesluite artikels {adding, select, true {is nie by {name} gevoeg nie} other {is nie uit {name} gehaal nie}}}}", + "problem": "{why, select, role {Jy kan {name} nou net bekyk, so ingesluite artikels {adding, select, true {word nie daarby gevoeg nie} other {word nie daaruit gehaal nie}}} notFound {{name} is nie meer in die Evidence Community nie, so ingesluite artikels {adding, select, true {word nie daarby gevoeg nie} other {word nie daaruit gehaal nie}}} full {Jou werkruimte het soveel versamelings as wat sy plan toelaat, so ingesluite artikels word nie in {name} gestoor nie. Skrap 'n versameling of kies in Instellings waarheen hulle gaan.} other {Die Evidence Community het nie geantwoord nie, so sommige ingesluite artikels {adding, select, true {is nie by {name} gevoeg nie} other {is nie uit {name} gehaal nie}}}}", "title": "Ingesluite artikels gaan na", "helpTitle": "Waarheen ingesluite artikels gaan", "savedEach": "Gestoor soos elkeen ingesluit word", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, one {# lesing het misluk} other {# lesings het misluk}}", "arriving": "Die artikels kom nog aan", "allRead": "Niks bly oor vir die modelle om te lees nie", - "leftIn": "{own, select, true {{credits} oor} other {{credits} oor in {workspace}}}", "takenOff": "{credits} deur modelle wat afgehaal is", "nothingToPay": "Niks om te betaal nie" }, diff --git a/messages/ar.json b/messages/ar.json index 0e147a917..ee6f7c38f 100644 --- a/messages/ar.json +++ b/messages/ar.json @@ -7964,7 +7964,8 @@ "says": "الملفات كما ستنزّلها، من دون ما هو مخفي عنك. تصلك الردود.", "send": "إرسال", "sent": "{count, plural, one {أُرسل الملف إلى {to}} other {أُرسلت # ملفات إلى {to}}}", - "failed": "لم تُرسل الملفات" + "failed": "لم تُرسل الملفات", + "tooLarge": "{count, plural, one {هذا الملف أكبر من أن يُرسل بالبريد الإلكتروني. نزّله بدلًا من ذلك.} other {هذه الملفات أكبر من أن تُرسل في رسالة واحدة. أرسل عددًا أقل، أو نزّلها.}}" }, "title": "تصدير", "description": "الأوراق، وكل الأصوات، ومخطط PRISMA، وفقرة المنهجية، والسجل الكامل", @@ -8824,7 +8825,7 @@ "onItsWay": "ملف PDF في الطريق", "cantShow": "لا يمكن عرض ملف PDF هذا هنا. افتحه في علامة تبويب جديدة." }, - "perPaper": "{credits, plural, zero {# رصيد} one {رصيد واحد} two {رصيدان} few {# أرصدة} many {# رصيدًا} other {# رصيد}} لكل ورقة", + "perPaper": "نحو {credits, plural, zero {# رصيد} one {رصيد واحد} two {رصيدين} few {# أرصدة} many {# رصيدًا} other {# رصيد}} لكل ورقة", "pickerCost": "الرصيد لكل ورقة" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, zero {# ورقة تعذّرت عليه قراءتها} one {ورقة واحدة تعذّرت عليه قراءتها} two {ورقتان تعذّرت عليه قراءتهما} few {# أوراق تعذّرت عليه قراءتها} many {# ورقة تعذّرت عليه قراءتها} other {# ورقة تعذّرت عليه قراءتها}}", "unread": "تعذّرت قراءة {count, number}", "unreadSays": "{count, plural, zero {تعذّرت عليه قراءة هذه الأوراق الـ#، فلا رأي له فيها.} one {تعذّرت عليه قراءة هذه الورقة، فلا رأي له فيها.} two {تعذّرت عليه قراءة هاتين الورقتين، فلا رأي له فيهما.} few {تعذّرت عليه قراءة هذه الأوراق الـ#، فلا رأي له فيها.} many {تعذّرت عليه قراءة هذه الأوراق الـ#، فلا رأي له فيها.} other {تعذّرت عليه قراءة هذه الأوراق الـ#، فلا رأي له فيها.}}", - "notGivenText": "{count, plural, zero {لم يُكلَّف بملفات PDF الـ#، لأنه يقرأ النص فقط} one {لم يُكلَّف بملف PDF، لأنه يقرأ النص فقط} two {لم يُكلَّف بملفي PDF، لأنه يقرأ النص فقط} few {لم يُكلَّف بملفات PDF الـ#، لأنه يقرأ النص فقط} many {لم يُكلَّف بملفات PDF الـ#، لأنه يقرأ النص فقط} other {لم يُكلَّف بملفات PDF الـ#، لأنه يقرأ النص فقط}}", - "notGivenLong": "{count, plural, zero {لم يُكلَّف بـ# ملف PDF أطول مما يقرؤه دفعة واحدة} one {لم يُكلَّف بملف PDF واحد أطول مما يقرؤه دفعة واحدة} two {لم يُكلَّف بملفي PDF أطول مما يقرؤه دفعة واحدة} few {لم يُكلَّف بـ# ملفات PDF أطول مما يقرؤه دفعة واحدة} many {لم يُكلَّف بـ# ملف PDF أطول مما يقرؤه دفعة واحدة} other {لم يُكلَّف بـ# ملف PDF أطول مما يقرؤه دفعة واحدة}}", "voted": "{decision, select, include {{count, number} صوّت بالإدراج} maybe {{count, number} صوّت بربما} other {{count, number} صوّت بالاستبعاد}}", "noOtherPerson": "لا شخص آخر للمقارنة", "aloneOnPapers": "لا يقرأ أي شخص آخر أوراقه", @@ -8973,7 +8972,7 @@ "startedIt": "بدأه {ago}" }, "included": { - "problem": "{why, select, role {يمكنك الآن عرض {name} فقط، لذا {adding, select, true {لا تُضاف الأوراق المُدرَجة إليها} other {لا تُزال الأوراق المُدرَجة منها}}} notFound {لم تعد {name} موجودة في Evidence Community، لذا {adding, select, true {لا تُضاف الأوراق المُدرَجة إليها} other {لا تُزال الأوراق المُدرَجة منها}}} other {لم تستجب Evidence Community، لذا {adding, select, true {لم تُضف بعض الأوراق المُدرَجة إلى {name}} other {لم تُزل بعض الأوراق المُدرَجة من {name}}}}}", + "problem": "{why, select, role {يمكنك الآن عرض {name} فقط، لذا {adding, select, true {لا تُضاف الأوراق المُدرَجة إليها} other {لا تُزال الأوراق المُدرَجة منها}}} notFound {لم تعد {name} موجودة في Evidence Community، لذا {adding, select, true {لا تُضاف الأوراق المُدرَجة إليها} other {لا تُزال الأوراق المُدرَجة منها}}} full {وصلت مساحة عملك إلى أقصى عدد من المجموعات تسمح به خطتها، لذا لا تُحفظ الأوراق المُدرَجة في {name}. احذف مجموعة أو اختر وجهتها في الإعدادات.} other {لم تستجب Evidence Community، لذا {adding, select, true {لم تُضف بعض الأوراق المُدرَجة إلى {name}} other {لم تُزل بعض الأوراق المُدرَجة من {name}}}}}", "title": "تذهب الأوراق المُدرَجة إلى", "helpTitle": "وجهة الأوراق المُدرَجة", "savedEach": "تُحفظ كل ورقة فور إدراجها", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, zero {فشلت # قراءة} one {فشلت قراءة واحدة} two {فشلت قراءتان} few {فشلت # قراءات} many {فشلت # قراءة} other {فشلت # قراءة}}", "arriving": "لا تزال الأوراق تصل", "allRead": "لم يبقَ شيء لتقرأه النماذج", - "leftIn": "{own, select, true {يتبقى {credits}} other {يتبقى {credits} في {workspace}}}", "takenOff": "{credits} من نماذج أُزيلت", "nothingToPay": "لا شيء للدفع" }, diff --git a/messages/de.json b/messages/de.json index 5a82a4d29..db977ee05 100644 --- a/messages/de.json +++ b/messages/de.json @@ -7964,7 +7964,8 @@ "says": "Die Dateien sind so, wie Sie sie herunterladen würden, ohne das, was vor Ihnen verborgen ist. Antworten gehen an Sie.", "send": "Senden", "sent": "{count, plural, one {Datei an {to} gesendet} other {# Dateien an {to} gesendet}}", - "failed": "Die Dateien wurden nicht gesendet" + "failed": "Die Dateien wurden nicht gesendet", + "tooLarge": "{count, plural, one {Diese Datei ist zu groß für eine E-Mail. Lade sie stattdessen herunter.} other {Diese Dateien sind zusammen zu groß für eine E-Mail. Sende weniger oder lade sie herunter.}}" }, "title": "Exportieren", "description": "Die Artikel, alle Stimmen, das PRISMA-Diagramm, ein Methodenabsatz und das vollständige Protokoll", @@ -8824,7 +8825,7 @@ "onItsWay": "Das PDF ist unterwegs", "cantShow": "Dieses PDF kann hier nicht angezeigt werden. Öffnen Sie es in einem neuen Tab." }, - "perPaper": "{credits, plural, one {# Credit} other {# Credits}} pro Artikel", + "perPaper": "Etwa {credits, plural, one {# Credit} other {# Credits}} pro Artikel", "pickerCost": "Credits pro Artikel" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, one {# Artikel, den es nicht lesen konnte} other {# Artikel, die es nicht lesen konnte}}", "unread": "{count, number} nicht lesbar", "unreadSays": "{count, plural, one {Es konnte diesen Artikel nicht lesen und hat darüber nicht mitzureden.} other {Es konnte diese # Artikel nicht lesen und hat darüber nicht mitzureden.}}", - "notGivenText": "{count, plural, one {Bekommt das PDF nicht, da es nur Text liest} other {Bekommt die # PDFs nicht, da es nur Text liest}}", - "notGivenLong": "{count, plural, one {Bekommt # PDF nicht, das länger ist, als es auf einmal liest} other {Bekommt # PDFs nicht, die länger sind, als es auf einmal liest}}", "voted": "{decision, select, include {{count, number} für Einschließen gestimmt} maybe {{count, number} für Vielleicht gestimmt} other {{count, number} für Ausschließen gestimmt}}", "noOtherPerson": "Keine andere Person zum Vergleich", "aloneOnPapers": "Niemand sonst liest diese Paper", @@ -8973,7 +8972,7 @@ "startedIt": "hat es {ago} gestartet" }, "included": { - "problem": "{why, select, role {Sie können {name} jetzt nur noch ansehen, daher werden eingeschlossene Artikel {adding, select, true {nicht dort hinzugefügt} other {nicht daraus entfernt}}} notFound {{name} ist nicht mehr in der Evidence Community, daher werden eingeschlossene Artikel {adding, select, true {nicht dort hinzugefügt} other {nicht daraus entfernt}}} other {Die Evidence Community hat nicht geantwortet, daher wurden einige eingeschlossene Artikel {adding, select, true {nicht zu {name} hinzugefügt} other {nicht aus {name} entfernt}}}}", + "problem": "{why, select, role {Sie können {name} jetzt nur noch ansehen, daher werden eingeschlossene Artikel {adding, select, true {nicht dort hinzugefügt} other {nicht daraus entfernt}}} notFound {{name} ist nicht mehr in der Evidence Community, daher werden eingeschlossene Artikel {adding, select, true {nicht dort hinzugefügt} other {nicht daraus entfernt}}} full {Ihr Arbeitsbereich hat so viele Sammlungen, wie sein Tarif erlaubt, daher werden eingeschlossene Artikel nicht in {name} gespeichert. Löschen Sie eine Sammlung oder wählen Sie in den Einstellungen, wohin sie gehen.} other {Die Evidence Community hat nicht geantwortet, daher wurden einige eingeschlossene Artikel {adding, select, true {nicht zu {name} hinzugefügt} other {nicht aus {name} entfernt}}}}", "title": "Ziel für eingeschlossene Artikel", "helpTitle": "Wohin eingeschlossene Artikel gehen", "savedEach": "Gespeichert, sobald jeder eingeschlossen ist", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, one {# Lesevorgang fehlgeschlagen} other {# Lesevorgänge fehlgeschlagen}}", "arriving": "Die Artikel kommen noch an", "allRead": "Für die Modelle bleibt nichts zu lesen", - "leftIn": "{own, select, true {{credits} übrig} other {{credits} übrig in {workspace}}}", "takenOff": "{credits} durch entfernte Modelle", "nothingToPay": "Nichts zu bezahlen" }, diff --git a/messages/en-GB.json b/messages/en-GB.json index 9d3e9ce4a..3cbcdeacf 100644 --- a/messages/en-GB.json +++ b/messages/en-GB.json @@ -7963,7 +7963,8 @@ "says": "The files are as you would download them, with what is hidden from you left out. Replies come to you.", "send": "Send", "sent": "{count, plural, one {Sent the file to {to}} other {Sent # files to {to}}}", - "failed": "The files weren’t sent" + "failed": "The files weren’t sent", + "tooLarge": "{count, plural, one {This file is too large for an email. Download it instead.} other {These files are too large for one email. Send fewer, or download them.}}" }, "title": "Export", "description": "The papers, every vote, the PRISMA diagram, a methods paragraph and the whole record", @@ -8823,7 +8824,7 @@ "onItsWay": "The PDF is on its way", "cantShow": "This PDF can't be shown here. Open it in a new tab." }, - "perPaper": "{credits, plural, one {# credit} other {# credits}} a paper", + "perPaper": "About {credits, plural, one {# credit} other {# credits}} a paper", "pickerCost": "Credits a paper" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, one {# paper it couldn't read} other {# papers it couldn't read}}", "unread": "{count, number} couldn't be read", "unreadSays": "{count, plural, one {It couldn't read this paper, so it has no say in it.} other {It couldn't read these # papers, so it has no say in them.}}", - "notGivenText": "{count, plural, one {Not given the PDF, as it reads text only} other {Not given the # PDFs, as it reads text only}}", - "notGivenLong": "{count, plural, one {Not given # PDF that is longer than it reads at once} other {Not given # PDFs that are longer than it reads at once}}", "voted": "{decision, select, include {{count, number} voted Include} maybe {{count, number} voted Maybe} other {{count, number} voted Exclude}}", "noOtherPerson": "No other person to compare with", "aloneOnPapers": "No other person reads their papers", @@ -8972,7 +8971,7 @@ "startedIt": "started it {ago}" }, "included": { - "problem": "{why, select, role {You can only view {name} now, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} notFound {{name} is no longer in the community, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} other {The community didn't answer, so some included papers {adding, select, true {weren't added to {name}} other {weren't taken out of {name}}}}}", + "problem": "{why, select, role {You can only view {name} now, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} notFound {{name} is no longer in the community, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} full {Your workspace has as many collections as its plan allows, so included papers aren't saved to {name}. Delete a collection or choose where they go in Settings.} other {The community didn't answer, so some included papers {adding, select, true {weren't added to {name}} other {weren't taken out of {name}}}}}", "title": "Included papers go to", "helpTitle": "Where included papers go", "savedEach": "Saved as each is included", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, one {# reading failed} other {# readings failed}}", "arriving": "Papers are still arriving", "allRead": "Nothing left for the models to read", - "leftIn": "{own, select, true {{credits} left} other {{credits} left in {workspace}}}", "takenOff": "{credits} by models taken off", "nothingToPay": "Nothing to pay" }, diff --git a/messages/en-US.json b/messages/en-US.json index 624d5d395..e148db27f 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -7963,7 +7963,8 @@ "says": "The files are as you would download them, with what is hidden from you left out. Replies come to you.", "send": "Send", "sent": "{count, plural, one {Sent the file to {to}} other {Sent # files to {to}}}", - "failed": "The files weren’t sent" + "failed": "The files weren’t sent", + "tooLarge": "{count, plural, one {This file is too large for an email. Download it instead.} other {These files are too large for one email. Send fewer, or download them.}}" }, "title": "Export", "description": "The papers, every vote, the PRISMA diagram, a methods paragraph and the whole record", @@ -8823,7 +8824,7 @@ "onItsWay": "The PDF is on its way", "cantShow": "This PDF can't be shown here. Open it in a new tab." }, - "perPaper": "{credits, plural, one {# credit} other {# credits}} a paper", + "perPaper": "About {credits, plural, one {# credit} other {# credits}} a paper", "pickerCost": "Credits a paper" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, one {# paper it couldn't read} other {# papers it couldn't read}}", "unread": "{count, number} couldn't be read", "unreadSays": "{count, plural, one {It couldn't read this paper, so it has no say in it.} other {It couldn't read these # papers, so it has no say in them.}}", - "notGivenText": "{count, plural, one {Not given the PDF, as it reads text only} other {Not given the # PDFs, as it reads text only}}", - "notGivenLong": "{count, plural, one {Not given # PDF that is longer than it reads at once} other {Not given # PDFs that are longer than it reads at once}}", "voted": "{decision, select, include {{count, number} voted Include} maybe {{count, number} voted Maybe} other {{count, number} voted Exclude}}", "noOtherPerson": "No other person to compare with", "aloneOnPapers": "No other person reads their papers", @@ -8972,7 +8971,7 @@ "startedIt": "started it {ago}" }, "included": { - "problem": "{why, select, role {You can only view {name} now, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} notFound {{name} is no longer in the community, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} other {The community didn't answer, so some included papers {adding, select, true {weren't added to {name}} other {weren't taken out of {name}}}}}", + "problem": "{why, select, role {You can only view {name} now, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} notFound {{name} is no longer in the community, so included papers {adding, select, true {aren't added to it} other {aren't taken out of it}}} full {Your workspace has as many collections as its plan allows, so included papers aren't saved to {name}. Delete a collection or choose where they go in Settings.} other {The community didn't answer, so some included papers {adding, select, true {weren't added to {name}} other {weren't taken out of {name}}}}}", "title": "Included papers go to", "helpTitle": "Where included papers go", "savedEach": "Saved as each is included", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, one {# reading failed} other {# readings failed}}", "arriving": "Papers are still arriving", "allRead": "Nothing left for the models to read", - "leftIn": "{own, select, true {{credits} left} other {{credits} left in {workspace}}}", "takenOff": "{credits} by models taken off", "nothingToPay": "Nothing to pay" }, diff --git a/messages/es.json b/messages/es.json index c947ce5a2..3b228f69b 100644 --- a/messages/es.json +++ b/messages/es.json @@ -7964,7 +7964,8 @@ "says": "Los archivos son como los descargaría, sin lo que está oculto para usted. Las respuestas le llegan a usted.", "send": "Enviar", "sent": "{count, plural, one {Archivo enviado a {to}} other {# archivos enviados a {to}}}", - "failed": "Los archivos no se enviaron" + "failed": "Los archivos no se enviaron", + "tooLarge": "{count, plural, one {Este archivo es demasiado grande para un correo. Descárgalo en su lugar.} other {Estos archivos son demasiado grandes para un solo correo. Envía menos o descárgalos.}}" }, "title": "Exportar", "description": "Los artículos, todos los votos, el diagrama PRISMA, un párrafo de métodos y el registro completo", @@ -8824,7 +8825,7 @@ "onItsWay": "El PDF está en camino", "cantShow": "Este PDF no se puede mostrar aquí. Ábralo en una pestaña nueva." }, - "perPaper": "{credits, plural, one {# crédito} other {# créditos}} por artículo", + "perPaper": "Unos {credits, plural, one {# crédito} other {# créditos}} por artículo", "pickerCost": "Créditos por artículo" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, one {# artículo que no pudo leer} other {# artículos que no pudo leer}}", "unread": "{count, number} no se pudieron leer", "unreadSays": "{count, plural, one {No pudo leer este artículo, así que no opina sobre él.} other {No pudo leer estos # artículos, así que no opina sobre ellos.}}", - "notGivenText": "{count, plural, one {No recibe el PDF, porque solo lee texto} other {No recibe los # PDF, porque solo lee texto}}", - "notGivenLong": "{count, plural, one {No recibe # PDF más largo de lo que lee de una vez} other {No recibe # PDF más largos de lo que lee de una vez}}", "voted": "{decision, select, include {{count, number} votados Incluir} maybe {{count, number} votados Quizá} other {{count, number} votados Excluir}}", "noOtherPerson": "No hay otra persona con quien comparar", "aloneOnPapers": "Ninguna otra persona lee sus artículos", @@ -8973,7 +8972,7 @@ "startedIt": "lo empezó {ago}" }, "included": { - "problem": "{why, select, role {Ahora solo puede ver {name}, así que los artículos incluidos {adding, select, true {no se añaden a ella} other {no se quitan de ella}}} notFound {{name} ya no está en la Evidence Community, así que los artículos incluidos {adding, select, true {no se añaden a ella} other {no se quitan de ella}}} other {La Evidence Community no respondió, así que algunos artículos incluidos {adding, select, true {no se añadieron a {name}} other {no se quitaron de {name}}}}}", + "problem": "{why, select, role {Ahora solo puede ver {name}, así que los artículos incluidos {adding, select, true {no se añaden a ella} other {no se quitan de ella}}} notFound {{name} ya no está en la Evidence Community, así que los artículos incluidos {adding, select, true {no se añaden a ella} other {no se quitan de ella}}} full {Tu espacio de trabajo tiene tantas colecciones como permite su plan, así que los artículos incluidos no se guardan en {name}. Elimina una colección o elige en Ajustes adónde van.} other {La Evidence Community no respondió, así que algunos artículos incluidos {adding, select, true {no se añadieron a {name}} other {no se quitaron de {name}}}}}", "title": "Los artículos incluidos van a", "helpTitle": "Adónde van los artículos incluidos", "savedEach": "Se guarda cada uno al incluirse", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, one {# lectura fallida} other {# lecturas fallidas}}", "arriving": "Los artículos aún están llegando", "allRead": "No queda nada por leer para los modelos", - "leftIn": "{own, select, true {Quedan {credits}} other {Quedan {credits} en {workspace}}}", "takenOff": "{credits} de modelos retirados", "nothingToPay": "Nada que pagar" }, diff --git a/messages/fr.json b/messages/fr.json index 1cab946da..10c30c857 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -7963,7 +7963,8 @@ "says": "Les fichiers sont tels que vous les téléchargeriez, sans ce qui vous est caché. Les réponses vous parviennent.", "send": "Envoyer", "sent": "{count, plural, one {Fichier envoyé à {to}} other {# fichiers envoyés à {to}}}", - "failed": "Les fichiers n’ont pas été envoyés" + "failed": "Les fichiers n’ont pas été envoyés", + "tooLarge": "{count, plural, one {Ce fichier est trop volumineux pour un e-mail. Téléchargez-le plutôt.} other {Ces fichiers sont trop volumineux pour un seul e-mail. Envoyez-en moins, ou téléchargez-les.}}" }, "title": "Exporter", "description": "Les articles, chaque vote, le diagramme PRISMA, un paragraphe de méthodes et le dossier complet", @@ -8823,7 +8824,7 @@ "onItsWay": "Le PDF arrive", "cantShow": "Ce PDF ne peut pas s'afficher ici. Ouvrez-le dans un nouvel onglet." }, - "perPaper": "{credits, plural, one {# crédit} other {# crédits}} par article", + "perPaper": "Environ {credits, plural, one {# crédit} other {# crédits}} par article", "pickerCost": "Crédits par article" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, one {# article qu'il n'a pas pu lire} other {# articles qu'il n'a pas pu lire}}", "unread": "{count, number} illisibles", "unreadSays": "{count, plural, one {Il n'a pas pu lire cet article, il ne compte donc pas dans sa décision.} other {Il n'a pas pu lire ces # articles, il ne compte donc pas dans leur décision.}}", - "notGivenText": "{count, plural, one {Le PDF ne lui est pas confié, car il ne lit que du texte} other {Les # PDF ne lui sont pas confiés, car il ne lit que du texte}}", - "notGivenLong": "{count, plural, one {# PDF trop long pour une seule lecture ne lui est pas confié} other {# PDF trop longs pour une seule lecture ne lui sont pas confiés}}", "voted": "{decision, select, include {{count, number} votés Inclure} maybe {{count, number} votés Peut-être} other {{count, number} votés Exclure}}", "noOtherPerson": "Aucune autre personne avec qui comparer", "aloneOnPapers": "Personne d’autre ne lit ses articles", @@ -8972,7 +8971,7 @@ "startedIt": "l'a démarré {ago}" }, "included": { - "problem": "{why, select, role {Vous ne pouvez plus que consulter {name}, donc les articles inclus {adding, select, true {n'y sont pas ajoutés} other {n'en sont pas retirés}}} notFound {{name} n'est plus dans l'Evidence Community, donc les articles inclus {adding, select, true {n'y sont pas ajoutés} other {n'en sont pas retirés}}} other {L'Evidence Community n'a pas répondu, donc certains articles inclus {adding, select, true {n'ont pas été ajoutés à {name}} other {n'ont pas été retirés de {name}}}}}", + "problem": "{why, select, role {Vous ne pouvez plus que consulter {name}, donc les articles inclus {adding, select, true {n'y sont pas ajoutés} other {n'en sont pas retirés}}} notFound {{name} n'est plus dans l'Evidence Community, donc les articles inclus {adding, select, true {n'y sont pas ajoutés} other {n'en sont pas retirés}}} full {Votre espace de travail a autant de collections que son forfait le permet, donc les articles inclus ne sont pas enregistrés dans {name}. Supprimez une collection ou choisissez où ils vont dans les Paramètres.} other {L'Evidence Community n'a pas répondu, donc certains articles inclus {adding, select, true {n'ont pas été ajoutés à {name}} other {n'ont pas été retirés de {name}}}}}", "title": "Les articles inclus vont dans", "helpTitle": "Où vont les articles inclus", "savedEach": "Enregistrés à mesure qu'ils sont inclus", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, one {# lecture a échoué} other {# lectures ont échoué}}", "arriving": "Les articles arrivent encore", "allRead": "Il ne reste rien à lire pour les modèles", - "leftIn": "{own, select, true {{credits} restants} other {{credits} restants dans {workspace}}}", "takenOff": "{credits} par des modèles retirés", "nothingToPay": "Rien à payer" }, diff --git a/messages/hi.json b/messages/hi.json index b31ac3108..30c76ad4f 100644 --- a/messages/hi.json +++ b/messages/hi.json @@ -7963,7 +7963,8 @@ "says": "फ़ाइलें वैसी ही हैं जैसी आप डाउनलोड करते, जो आपसे छिपा है वह छोड़कर। जवाब आपको मिलते हैं।", "send": "भेजें", "sent": "{count, plural, one {फ़ाइल {to} को भेजी गई} other {# फ़ाइलें {to} को भेजी गईं}}", - "failed": "फ़ाइलें नहीं भेजी गईं" + "failed": "फ़ाइलें नहीं भेजी गईं", + "tooLarge": "{count, plural, one {यह फ़ाइल ईमेल के लिए बहुत बड़ी है। इसके बजाय इसे डाउनलोड करें।} other {ये फ़ाइलें एक ईमेल के लिए बहुत बड़ी हैं। कम भेजें, या इन्हें डाउनलोड करें।}}" }, "title": "निर्यात", "description": "लेख, हर वोट, PRISMA आरेख, विधि का एक अनुच्छेद और पूरा रिकॉर्ड", @@ -8823,7 +8824,7 @@ "onItsWay": "PDF आ रही है", "cantShow": "यह PDF यहाँ नहीं दिखाई जा सकती। इसे नए टैब में खोलें।" }, - "perPaper": "प्रति लेख {credits, plural, one {# क्रेडिट} other {# क्रेडिट}}", + "perPaper": "प्रति लेख लगभग {credits, plural, one {# क्रेडिट} other {# क्रेडिट}}", "pickerCost": "प्रति लेख क्रेडिट" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, one {# लेख जिसे यह नहीं पढ़ सका} other {# लेख जिन्हें यह नहीं पढ़ सका}}", "unread": "{count, number} पढ़े नहीं जा सके", "unreadSays": "{count, plural, one {यह इस लेख को नहीं पढ़ सका, इसलिए इस पर इसका कोई फ़ैसला नहीं।} other {यह इन # लेखों को नहीं पढ़ सका, इसलिए इन पर इसका कोई फ़ैसला नहीं।}}", - "notGivenText": "{count, plural, one {PDF नहीं दी गई, क्योंकि यह केवल टेक्स्ट पढ़ता है} other {# PDF नहीं दी गईं, क्योंकि यह केवल टेक्स्ट पढ़ता है}}", - "notGivenLong": "{count, plural, one {एक बार में जितना यह पढ़ता है उससे लंबी # PDF नहीं दी गई} other {एक बार में जितना यह पढ़ता है उससे लंबी # PDF नहीं दी गईं}}", "voted": "{decision, select, include {{count, number} पर शामिल करें का वोट} maybe {{count, number} पर शायद का वोट} other {{count, number} पर बाहर करें का वोट}}", "noOtherPerson": "तुलना के लिए कोई दूसरा व्यक्ति नहीं", "aloneOnPapers": "उनके पेपर कोई और व्यक्ति नहीं पढ़ता", @@ -8972,7 +8971,7 @@ "startedIt": "ने इसे {ago} शुरू किया" }, "included": { - "problem": "{why, select, role {अब आप {name} को केवल देख सकते हैं, इसलिए शामिल लेख {adding, select, true {उसमें नहीं जोड़े जाते} other {उससे नहीं निकाले जाते}}} notFound {{name} अब कम्युनिटी में नहीं है, इसलिए शामिल लेख {adding, select, true {उसमें नहीं जोड़े जाते} other {उससे नहीं निकाले जाते}}} other {कम्युनिटी ने जवाब नहीं दिया, इसलिए कुछ शामिल लेख {adding, select, true {{name} में नहीं जोड़े गए} other {{name} से नहीं निकाले गए}}}}", + "problem": "{why, select, role {अब आप {name} को केवल देख सकते हैं, इसलिए शामिल लेख {adding, select, true {उसमें नहीं जोड़े जाते} other {उससे नहीं निकाले जाते}}} notFound {{name} अब कम्युनिटी में नहीं है, इसलिए शामिल लेख {adding, select, true {उसमें नहीं जोड़े जाते} other {उससे नहीं निकाले जाते}}} full {आपके कार्यक्षेत्र में उतने संग्रह हैं जितने उसकी योजना अनुमति देती है, इसलिए शामिल लेख {name} में सहेजे नहीं जाते। कोई संग्रह हटाएँ या सेटिंग्स में चुनें कि वे कहाँ जाएँ।} other {कम्युनिटी ने जवाब नहीं दिया, इसलिए कुछ शामिल लेख {adding, select, true {{name} में नहीं जोड़े गए} other {{name} से नहीं निकाले गए}}}}", "title": "शामिल लेख यहाँ जाते हैं", "helpTitle": "शामिल लेख कहाँ जाते हैं", "savedEach": "हर लेख शामिल होते ही सहेजा जाता है", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, one {# बार पढ़ना विफल} other {# बार पढ़ना विफल}}", "arriving": "लेख अभी आ रहे हैं", "allRead": "मॉडलों के पढ़ने के लिए कुछ नहीं बचा", - "leftIn": "{own, select, true {{credits} बचे} other {{workspace} में {credits} बचे}}", "takenOff": "हटाए गए मॉडलों के {credits}", "nothingToPay": "कोई भुगतान नहीं" }, diff --git a/messages/ja.json b/messages/ja.json index b1e250313..08dff626d 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -7963,7 +7963,8 @@ "says": "ファイルはダウンロードするときと同じ内容で、あなたに非表示のものは含まれません。返信はあなたに届きます。", "send": "送信", "sent": "{count, plural, other {{to} に # 件のファイルを送りました}}", - "failed": "ファイルを送れませんでした" + "failed": "ファイルを送れませんでした", + "tooLarge": "{count, plural, one {このファイルはメールで送るには大きすぎます。代わりにダウンロードしてください。} other {これらのファイルは1通のメールには大きすぎます。数を減らすか、ダウンロードしてください。}}" }, "title": "エクスポート", "description": "論文、すべての投票、PRISMA 図、方法の段落、記録全体", @@ -8823,7 +8824,7 @@ "onItsWay": "PDF を取得中です", "cantShow": "この PDF はここに表示できません。新しいタブで開いてください。" }, - "perPaper": "論文 1 件あたり {credits, plural, other {# クレジット}}", + "perPaper": "論文 1 件あたり約 {credits, plural, other {# クレジット}}", "pickerCost": "論文 1 件あたりのクレジット" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, other {読み取れなかった論文 # 件}}", "unread": "{count, number} 件を読み取れませんでした", "unreadSays": "{count, plural, other {この論文 # 件を読み取れなかったため、その結果には関わりません。}}", - "notGivenText": "{count, plural, other {テキストしか読めないため、PDF # 件は割り当てられていません}}", - "notGivenLong": "{count, plural, other {一度に読める長さを超える PDF # 件は割り当てられていません}}", "voted": "{decision, select, include {採用に投票 {count, number} 件} maybe {保留に投票 {count, number} 件} other {除外に投票 {count, number} 件}}", "noOtherPerson": "比べるほかの人がいません", "aloneOnPapers": "この人の論文を読む人はほかにいません", @@ -8972,7 +8971,7 @@ "startedIt": "{ago}に開始" }, "included": { - "problem": "{why, select, role {{name} は閲覧のみになったため、採用した論文は{adding, select, true {そこに追加されません} other {そこから取り除かれません}}} notFound {{name} はもうコミュニティにないため、採用した論文は{adding, select, true {そこに追加されません} other {そこから取り除かれません}}} other {コミュニティから応答がなかったため、採用した論文の一部が{adding, select, true {{name} に追加されませんでした} other {{name} から取り除かれませんでした}}}}", + "problem": "{why, select, role {{name} は閲覧のみになったため、採用した論文は{adding, select, true {そこに追加されません} other {そこから取り除かれません}}} notFound {{name} はもうコミュニティにないため、採用した論文は{adding, select, true {そこに追加されません} other {そこから取り除かれません}}} full {ワークスペースのコレクション数がプランの上限に達しているため、採用した論文は {name} に保存されません。コレクションを削除するか、設定で保存先を選んでください。} other {コミュニティから応答がなかったため、採用した論文の一部が{adding, select, true {{name} に追加されませんでした} other {{name} から取り除かれませんでした}}}}", "title": "採用した論文の保存先", "helpTitle": "採用した論文の行き先", "savedEach": "採用されるたびに保存", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, other {読み取り失敗 # 回}}", "arriving": "論文はまだ届いています", "allRead": "モデルが読むものは残っていません", - "leftIn": "{own, select, true {残り {credits}} other {{workspace} に残り {credits}}}", "takenOff": "外されたモデルが {credits}", "nothingToPay": "支払いはありません" }, diff --git a/messages/pt.json b/messages/pt.json index f61a52431..a2161cf49 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -7964,7 +7964,8 @@ "says": "Os arquivos são como os baixaria, sem o que está oculto para você. As respostas chegam a você.", "send": "Enviar", "sent": "{count, plural, one {Arquivo enviado para {to}} other {# arquivos enviados para {to}}}", - "failed": "Os arquivos não foram enviados" + "failed": "Os arquivos não foram enviados", + "tooLarge": "{count, plural, one {Este arquivo é grande demais para um e-mail. Baixe-o em vez disso.} other {Estes arquivos são grandes demais para um único e-mail. Envie menos ou baixe-os.}}" }, "title": "Exportar", "description": "Os artigos, todos os votos, o diagrama PRISMA, um parágrafo de métodos e o registo completo", @@ -8824,7 +8825,7 @@ "onItsWay": "O PDF está a caminho", "cantShow": "Não é possível mostrar este PDF aqui. Abra-o num novo separador." }, - "perPaper": "{credits, plural, one {# crédito} other {# créditos}} por artigo", + "perPaper": "Cerca de {credits, plural, one {# crédito} other {# créditos}} por artigo", "pickerCost": "Créditos por artigo" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, one {# artigo que não conseguiu ler} other {# artigos que não conseguiu ler}}", "unread": "{count, number} não puderam ser lidos", "unreadSays": "{count, plural, one {Não conseguiu ler este artigo, por isso não tem voto nele.} other {Não conseguiu ler estes # artigos, por isso não tem voto neles.}}", - "notGivenText": "{count, plural, one {Não recebe o PDF, porque só lê texto} other {Não recebe os # PDF, porque só lê texto}}", - "notGivenLong": "{count, plural, one {Não recebe # PDF mais longo do que consegue ler de uma vez} other {Não recebe # PDF mais longos do que consegue ler de uma vez}}", "voted": "{decision, select, include {{count, number} votaram Incluir} maybe {{count, number} votaram Talvez} other {{count, number} votaram Excluir}}", "noOtherPerson": "Não há outra pessoa para comparar", "aloneOnPapers": "Nenhuma outra pessoa lê os artigos dessa pessoa", @@ -8973,7 +8972,7 @@ "startedIt": "iniciou-a {ago}" }, "included": { - "problem": "{why, select, role {Agora só pode ver {name}, por isso os artigos incluídos {adding, select, true {não são adicionados lá} other {não são retirados de lá}}} notFound {{name} já não está na comunidade, por isso os artigos incluídos {adding, select, true {não são adicionados lá} other {não são retirados de lá}}} other {A comunidade não respondeu, por isso alguns artigos incluídos {adding, select, true {não foram adicionados a {name}} other {não foram retirados de {name}}}}}", + "problem": "{why, select, role {Agora só pode ver {name}, por isso os artigos incluídos {adding, select, true {não são adicionados lá} other {não são retirados de lá}}} notFound {{name} já não está na comunidade, por isso os artigos incluídos {adding, select, true {não são adicionados lá} other {não são retirados de lá}}} full {Seu espaço de trabalho tem tantas coleções quanto o plano permite, então os artigos incluídos não são salvos em {name}. Exclua uma coleção ou escolha para onde eles vão nas Configurações.} other {A comunidade não respondeu, por isso alguns artigos incluídos {adding, select, true {não foram adicionados a {name}} other {não foram retirados de {name}}}}}", "title": "Os artigos incluídos vão para", "helpTitle": "Para onde vão os artigos incluídos", "savedEach": "Guardado à medida que cada um é incluído", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, one {# leitura falhou} other {# leituras falharam}}", "arriving": "Os artigos ainda estão a chegar", "allRead": "Não resta nada para os modelos lerem", - "leftIn": "{own, select, true {{credits} restantes} other {{credits} restantes em {workspace}}}", "takenOff": "{credits} de modelos retirados", "nothingToPay": "Nada a pagar" }, diff --git a/messages/sw.json b/messages/sw.json index 042284393..be292b5bf 100644 --- a/messages/sw.json +++ b/messages/sw.json @@ -7964,7 +7964,8 @@ "says": "Faili ni kama ungezipakua, bila kilichofichwa kwako. Majibu yanakuja kwako.", "send": "Tuma", "sent": "{count, plural, one {Faili imetumwa kwa {to}} other {Faili # zimetumwa kwa {to}}}", - "failed": "Faili hazikutumwa" + "failed": "Faili hazikutumwa", + "tooLarge": "{count, plural, one {Faili hii ni kubwa mno kwa barua pepe. Ipakue badala yake.} other {Faili hizi ni kubwa mno kwa barua pepe moja. Tuma chache, au uzipakue.}}" }, "title": "Hamisha", "description": "Makala, kila kura, mchoro wa PRISMA, aya ya mbinu na kumbukumbu nzima", @@ -8824,7 +8825,7 @@ "onItsWay": "PDF iko njiani", "cantShow": "PDF hii haiwezi kuonyeshwa hapa. Ifungue kwenye kichupo kipya." }, - "perPaper": "{credits, plural, one {krediti #} other {krediti #}} kwa kila makala", + "perPaper": "Takriban {credits, plural, one {krediti #} other {krediti #}} kwa kila makala", "pickerCost": "Krediti kwa kila makala" }, "overview": { @@ -8917,8 +8918,6 @@ "unreadLabel": "{count, plural, one {makala # ambayo haikuweza kusoma} other {makala # ambazo haikuweza kusoma}}", "unread": "{count, number} hazikuweza kusomwa", "unreadSays": "{count, plural, one {Haikuweza kusoma makala hii, kwa hivyo haina sauti juu yake.} other {Haikuweza kusoma makala hizi #, kwa hivyo haina sauti juu yake.}}", - "notGivenText": "{count, plural, one {Haipewi PDF, kwa kuwa inasoma maandishi tu} other {Haipewi PDF #, kwa kuwa inasoma maandishi tu}}", - "notGivenLong": "{count, plural, one {Haipewi PDF # iliyo ndefu kuliko inavyosoma kwa mara moja} other {Haipewi PDF # zilizo ndefu kuliko inavyosoma kwa mara moja}}", "voted": "{decision, select, include {{count, number} alipigia Jumuisha} maybe {{count, number} alipigia Labda} other {{count, number} alipigia Tenga}}", "noOtherPerson": "Hakuna mtu mwingine wa kulinganisha naye", "aloneOnPapers": "Hakuna mtu mwingine anayesoma makala zao", @@ -8973,7 +8972,7 @@ "startedIt": "aliuanzisha {ago}" }, "included": { - "problem": "{why, select, role {Sasa unaweza kutazama {name} tu, kwa hivyo makala zilizojumuishwa {adding, select, true {haziongezwi humo} other {haziondolewi humo}}} notFound {{name} haipo tena kwenye Evidence Community, kwa hivyo makala zilizojumuishwa {adding, select, true {haziongezwi humo} other {haziondolewi humo}}} other {Evidence Community haikujibu, kwa hivyo baadhi ya makala zilizojumuishwa {adding, select, true {hazikuongezwa kwenye {name}} other {hazikuondolewa kwenye {name}}}}}", + "problem": "{why, select, role {Sasa unaweza kutazama {name} tu, kwa hivyo makala zilizojumuishwa {adding, select, true {haziongezwi humo} other {haziondolewi humo}}} notFound {{name} haipo tena kwenye Evidence Community, kwa hivyo makala zilizojumuishwa {adding, select, true {haziongezwi humo} other {haziondolewi humo}}} full {Eneo lako la kazi lina mikusanyiko mingi kadiri mpango wake unavyoruhusu, kwa hivyo makala yaliyojumuishwa hayahifadhiwi kwenye {name}. Futa mkusanyiko au chagua yanakokwenda kwenye Mipangilio.} other {Evidence Community haikujibu, kwa hivyo baadhi ya makala zilizojumuishwa {adding, select, true {hazikuongezwa kwenye {name}} other {hazikuondolewa kwenye {name}}}}}", "title": "Makala zilizojumuishwa zinaenda", "helpTitle": "Makala zilizojumuishwa zinaenda wapi", "savedEach": "Inahifadhiwa kila moja inapojumuishwa", @@ -8997,7 +8996,6 @@ "failed": "{count, plural, one {usomaji # umeshindwa} other {usomaji # umeshindwa}}", "arriving": "Makala bado zinafika", "allRead": "Hakuna kilichobaki kwa miundo kusoma", - "leftIn": "{own, select, true {{credits} zimebaki} other {{credits} zimebaki kwenye {workspace}}}", "takenOff": "{credits} za modeli zilizoondolewa", "nothingToPay": "Hakuna cha kulipa" }, diff --git a/messages/zh.json b/messages/zh.json index 3f8636429..0c652a5e2 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -7963,7 +7963,8 @@ "says": "文件与你下载时相同,不含对你隐藏的内容。回复会发给你。", "send": "发送", "sent": "{count, plural, other {已将 # 个文件发送给 {to}}}", - "failed": "文件未发送" + "failed": "文件未发送", + "tooLarge": "{count, plural, one {此文件太大,无法通过邮件发送。请改为下载。} other {这些文件太大,无法放在一封邮件中。请少选几个,或下载它们。}}" }, "title": "导出", "description": "论文、所有投票、PRISMA 流程图、方法段落和完整记录", @@ -8823,7 +8824,7 @@ "onItsWay": "PDF 正在路上", "cantShow": "此 PDF 无法在这里显示。请在新标签页中打开。" }, - "perPaper": "每篇论文 {credits, plural, other {# 积分}}", + "perPaper": "每篇论文约 {credits, plural, other {# 积分}}", "pickerCost": "每篇论文积分" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, other {# 篇它无法读取的论文}}", "unread": "{count, number} 篇无法读取", "unreadSays": "{count, plural, other {它无法读取这 # 篇论文,因此对其没有发言权。}}", - "notGivenText": "{count, plural, other {未分配 # 个 PDF,因为它只读取文本}}", - "notGivenLong": "{count, plural, other {未分配 # 个超出它一次能读取长度的 PDF}}", "voted": "{decision, select, include {投了入选:{count, number}} maybe {投了待定:{count, number}} other {投了排除:{count, number}}}", "noOtherPerson": "没有其他人可比较", "aloneOnPapers": "没有其他人阅读其论文", @@ -8972,7 +8971,7 @@ "startedIt": "{ago}开始" }, "included": { - "problem": "{why, select, role {你现在只能查看 {name},因此入选论文{adding, select, true {不会添加到其中} other {不会从中移出}}} notFound {{name} 已不在文献社区中,因此入选论文{adding, select, true {不会添加到其中} other {不会从中移出}}} other {文献社区没有响应,因此部分入选论文{adding, select, true {未添加到 {name}} other {未从 {name} 移出}}}}", + "problem": "{why, select, role {你现在只能查看 {name},因此入选论文{adding, select, true {不会添加到其中} other {不会从中移出}}} notFound {{name} 已不在文献社区中,因此入选论文{adding, select, true {不会添加到其中} other {不会从中移出}}} full {你的工作区的合集数量已达到其方案的上限,因此纳入的论文不会保存到 {name}。请删除一个合集,或在设置中选择它们的去处。} other {文献社区没有响应,因此部分入选论文{adding, select, true {未添加到 {name}} other {未从 {name} 移出}}}}", "title": "入选论文保存到", "helpTitle": "入选论文去向", "savedEach": "每篇入选时即保存", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, other {# 次读取失败}}", "arriving": "论文仍在到达", "allRead": "模型已没有要读的内容", - "leftIn": "{own, select, true {剩余 {credits}} other {{workspace} 剩余 {credits}}}", "takenOff": "已移出的模型用了 {credits}", "nothingToPay": "无需付费" }, diff --git a/messages/zu.json b/messages/zu.json index 6decca7bf..ef6abfb3d 100644 --- a/messages/zu.json +++ b/messages/zu.json @@ -7963,7 +7963,8 @@ "says": "Amafayela anjengoba ubungawalanda, ngaphandle kwalokho okufihliwe kuwe. Izimpendulo zifika kuwe.", "send": "Thumela", "sent": "{count, plural, one {Ifayela lithunyelwe ku-{to}} other {Amafayela angu-# athunyelwe ku-{to}}}", - "failed": "Amafayela awathunyelwanga" + "failed": "Amafayela awathunyelwanga", + "tooLarge": "{count, plural, one {Leli fayela likhulu kakhulu ukuthi lingathunyelwa nge-imeyili. Lilande esikhundleni salokho.} other {Lawa mafayela makhulu kakhulu ukuthi angangena ku-imeyili eyodwa. Thumela ambalwa, noma uwalande.}}" }, "title": "Landa", "description": "Amaphepha, onke amavoti, umdwebo we-PRISMA, isigaba sezindlela kanye nerekhodi lonke", @@ -8823,7 +8824,7 @@ "onItsWay": "I-PDF isendleleni", "cantShow": "Le PDF ayikwazi ukuboniswa lapha. Yivule kuthebhu entsha." }, - "perPaper": "{credits, plural, one {# ikhredithi} other {# amakhredithi}} ngephepha", + "perPaper": "Cishe {credits, plural, one {# ikhredithi} other {# amakhredithi}} ngephepha", "pickerCost": "Amakhredithi ngephepha" }, "overview": { @@ -8916,8 +8917,6 @@ "unreadLabel": "{count, plural, one {# iphepha engakwazanga ukulifunda} other {# amaphepha engakwazanga ukuwafunda}}", "unread": "{count, number} awakwazanga ukufundwa", "unreadSays": "{count, plural, one {Ayikwazanga ukufunda leli phepha, ngakho ayinalo izwi kulo.} other {Ayikwazanga ukufunda la maphepha angu-#, ngakho ayinalo izwi kuwo.}}", - "notGivenText": "{count, plural, one {Ayinikwa i-PDF, ngoba ifunda umbhalo kuphela} other {Ayinikwa ama-PDF angu-#, ngoba ifunda umbhalo kuphela}}", - "notGivenLong": "{count, plural, one {Ayinikwa i-PDF engu-# ende kunalokho ekufundayo ngesikhathi esisodwa} other {Ayinikwa ama-PDF angu-# amade kunalokho ekufundayo ngesikhathi esisodwa}}", "voted": "{decision, select, include {{count, number} kuvotwe ngokuthi Faka} maybe {{count, number} kuvotwe ngokuthi Mhlawumbe} other {{count, number} kuvotwe ngokuthi Khipha}}", "noOtherPerson": "Akekho omunye umuntu wokuqhathanisa naye", "aloneOnPapers": "Akekho omunye umuntu ofunda amaphepha abo", @@ -8972,7 +8971,7 @@ "startedIt": "ukuqale {ago}" }, "included": { - "problem": "{why, select, role {Manje ungabuka kuphela i-{name}, ngakho amaphepha afakiwe {adding, select, true {awengezwa kuyo} other {awasuswa kuyo}}} notFound {I-{name} ayisekho ku-Evidence Community, ngakho amaphepha afakiwe {adding, select, true {awengezwa kuyo} other {awasuswa kuyo}}} other {I-Evidence Community ayiphendulanga, ngakho amanye amaphepha afakiwe {adding, select, true {awengezwanga ku-{name}} other {awasuswanga ku-{name}}}}}", + "problem": "{why, select, role {Manje ungabuka kuphela i-{name}, ngakho amaphepha afakiwe {adding, select, true {awengezwa kuyo} other {awasuswa kuyo}}} notFound {I-{name} ayisekho ku-Evidence Community, ngakho amaphepha afakiwe {adding, select, true {awengezwa kuyo} other {awasuswa kuyo}}} full {Indawo yakho yokusebenza inamaqoqo amaningi njengoba uhlelo lwayo luvumela, ngakho amaphepha afakiwe awagcinwa ku-{name}. Susa iqoqo noma ukhethe lapho eya khona kuZilungiselelo.} other {I-Evidence Community ayiphendulanga, ngakho amanye amaphepha afakiwe {adding, select, true {awengezwanga ku-{name}} other {awasuswanga ku-{name}}}}}", "title": "Amaphepha afakiwe aya ku-", "helpTitle": "Lapho amaphepha afakiwe aya khona", "savedEach": "Agcinwa njengoba ngalinye lifakwa", @@ -8996,7 +8995,6 @@ "failed": "{count, plural, one {# ukufunda kwehlulekile} other {# ukufunda kwehlulekile}}", "arriving": "Amaphepha asafika", "allRead": "Akukho okusele ukuba amamodeli akufunde", - "leftIn": "{own, select, true {{credits} kusele} other {{credits} kusele ku-{workspace}}}", "takenOff": "{credits} ngamamodeli asusiwe", "nothingToPay": "Akukho okukhokhwayo" }, diff --git a/scripts/convex-rules.json b/scripts/convex-rules.json index e9335bd85..57d4f7d1e 100644 --- a/scripts/convex-rules.json +++ b/scripts/convex-rules.json @@ -57,7 +57,7 @@ }, "refused": { "MAX_ROLLOUT_COMMUNITIES": "reads one past it and refuses to list or update communities, naming why", - "COUNTED": "reads one past it and gives no count: a screening's papers by where they stand, more than any plan gives one screening, so the Papers page's tabs then carry no number", + "VOTES_COUNTED": "reads one past it and gives no count: a reviewer's votes read whole for a count narrowed three ways, as many as fit one query's read, so that one count then carries no number", "MAX_ACCOUNTS_PER_EMAIL": "reads one past it and refuses the invitation, naming why", "MAX_ACTIVE_OPERATIONS_READ": "reads one past it and refuses the change until operations finish", "MAX_ORGANIZATIONS_PER_PERSON": "reads one past it and refuses: Clerk's webhooks write memberships, so no write here can",