From ced71caa75c7e48ebc397620efead32c33b25eae Mon Sep 17 00:00:00 2001 From: Saty <5752427+SatyPardus@users.noreply.github.com> Date: Sun, 18 Oct 2026 12:07:09 +0200 Subject: [PATCH] Peer reviews are handed out closest to a decision first Functions waiting for their 4th and 5th confirmation never came up while hundreds waited in peer review, so nothing was ever auto-accepted. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RNwtXPYqFu3oKaaXwYwNWW --- src/server/peer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server/peer.js b/src/server/peer.js index 3803c97..5e4971f 100644 --- a/src/server/peer.js +++ b/src/server/peer.js @@ -42,7 +42,11 @@ export class PeerReviews { return (this.project.matchPolicy.peerLeaseMinutes ?? 60) * 60_000; } - /** Attempts waiting for peer review that `user` may take. */ + /** + * Attempts waiting for peer review that `user` may take, closest to a decision first: a function + * one verdict short of acceptance (or of going back) beats one nobody has looked at yet, so + * decisions get finished instead of verdicts spread thinly over the whole queue. + */ available(user, limit = 20) { return this.store.all( `SELECT a.id AS attempt_id, a.batch_id, a.task_id, a.state, t.symbol_id, s.name, a.finished_at, @@ -53,7 +57,7 @@ export class PeerReviews { WHERE a.state IN ('peer_review', 'in_review') AND a.user_id != ? AND NOT EXISTS (SELECT 1 FROM users b WHERE b.id = ? AND b.peer_review_blocked = 1) AND NOT EXISTS (SELECT 1 FROM peer_reviews p WHERE p.attempt_id = a.id AND p.reviewer_id = ?) - ORDER BY a.state = 'in_review', a.finished_at + ORDER BY MAX(confirmations, objections) DESC, a.finished_at LIMIT ?`, now(), user.id,