🎲 Add random review task entry
This commit is contained in:
parent
0e30494488
commit
99e9e25ae6
@ -4164,6 +4164,50 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
}
|
||||
};
|
||||
|
||||
const randomReviewClaimTask = async () => {
|
||||
if (isManager || !reviewOnly || saving || loading || !projectId || !reviewDraftGuardRef.current()) return;
|
||||
const candidates = acceptanceWorkspace ? prepackageAcceptanceItems : visiblePoolItems;
|
||||
const candidate = candidates
|
||||
.filter(
|
||||
(item) =>
|
||||
!item.assignedUserId &&
|
||||
["ready", "rework", "submitted"].includes(item.status) &&
|
||||
canCurrentUserClaimItem(item),
|
||||
)
|
||||
.sort(() => Math.random() - 0.5)[0];
|
||||
if (!candidate) {
|
||||
setError("当前项目暂无可领取的审核任务");
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
setError("");
|
||||
try {
|
||||
const claimed = await humanLoopApi.claim(candidate.id, candidate.version);
|
||||
applyReviewClaim(claimed);
|
||||
setTaskPoolView("mine");
|
||||
const acceptance = claimed.currentStageId === "prepackage_acceptance";
|
||||
const taskId = acceptance ? "" : claimed.legacyTaskId || "";
|
||||
setSelectedAnnotationTaskId(taskId);
|
||||
setExpandedDeliveryPackageId(acceptance ? claimed.id : "");
|
||||
const next = new URLSearchParams(searchParams);
|
||||
next.set("projectId", projectId);
|
||||
next.delete("sliceId");
|
||||
next.delete("eventId");
|
||||
if (acceptance) {
|
||||
next.set("acceptanceId", claimed.id);
|
||||
next.delete("taskId");
|
||||
} else {
|
||||
next.set("taskId", taskId);
|
||||
next.delete("acceptanceId");
|
||||
}
|
||||
setSearchParams(next, { replace: true });
|
||||
} catch (cause) {
|
||||
setError(getActionErrorMessage(cause, "随机领取审核任务失败,请刷新后重试"));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Reconcile one account/project buffer without navigating or touching editor
|
||||
// drafts. Requests already in flight are recorded even after an immediate pause.
|
||||
const reconcileWorkBuffer = async (stillCurrent: () => boolean, refill = false) => {
|
||||
@ -5215,6 +5259,19 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{reviewOnly && !isManager && (
|
||||
<div className="mt-3 space-y-2" data-testid="review-random-claim">
|
||||
<p className="text-xs text-slate-500">从当前项目可领取池随机领取一条并直接进入审核。</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void randomReviewClaimTask()}
|
||||
disabled={!projectId || saving || loading || taskPoolView === "reviewed"}
|
||||
className="w-full rounded-lg bg-orange-500 px-3 py-2 font-semibold text-white disabled:opacity-50"
|
||||
>
|
||||
随机领取并开始审核
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{(!blindAnnotator || taskPoolView === "mine") && (
|
||||
<>
|
||||
<div className="annotation-task-pool-filters mt-3 grid gap-2">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user