summaryrefslogtreecommitdiffstats
path: root/src/db/candidates.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/candidates.rs')
-rw-r--r--src/db/candidates.rs24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index 63c089f..631bf42 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -1,22 +1,10 @@
-//! The candidate table: its row shape, its column list, and every statement
-//! that touches it (§7.1).
-//!
-//! The *rules* about candidates — collapse into the open review, supersede once
-//! a human has looked, never re-raise a rejection — are domain logic and live
-//! in `review::candidates`. What lives here is SQL, so that the schema has one
-//! owner (§6 M-1). The `_in` functions take a transaction handle so a caller
-//! can compose several of them into one atomic decision; the decision itself
-//! stays with the caller.
-
use rusqlite::{params, OptionalExtension, Row, Transaction};
use crate::db::{CandidateRow, CandidateState, Db};
use crate::error::{Error, Result};
use crate::time;
-/// The columns `row_to_candidate` reads, spelled once. Every other table in
-/// this module already works this way; the candidate select was simply copied
-/// four times for long enough to be noticed (§6 m-3).
+/// The columns `row_to_candidate` reads, spelled once (§6 m-3).
const CANDIDATE_COLS: &str = "c.id, c.pkgbase_id, c.base_release_id, c.kind, c.snapshot_id, c.epoch, c.pkgver, \
c.pkgrel, c.upstream_pins_json, c.source_digests_json, c.identity_hash, c.diff_digest, \
c.revision, c.viewed_at, c.risk_level, c.risk_signals_json, c.missing_deps_json, c.state, \
@@ -130,10 +118,8 @@ pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Opti
/// Take a candidate out of the open state: approved, rejected or superseded.
///
-/// The write is a compare-and-swap on [`CandidateState`]: a decided review is
-/// never re-decided, so an approval racing a rejection — or a stale worker
-/// resolving a review that has since been superseded — fails instead of
-/// silently overwriting what a human did.
+/// The write is a compare-and-swap on [`CandidateState`]: a decided review is never
+/// re-decided, so an approval racing a rejection fails instead of overwriting.
pub fn resolve_in(tx: &Transaction<'_>, id: i64, to: CandidateState, at: &str) -> Result<()> {
let froms = CandidateState::predecessors(to);
let placeholders = froms.iter().map(|_| "?").collect::<Vec<_>>().join(",");
@@ -233,7 +219,7 @@ pub fn supersede_in(tx: &Transaction<'_>, id: i64) -> Result<()> {
}
/// Has this exact identity been rejected before? If so the watcher stays quiet
-/// until a human re-opens it (§7.1: "do not nag").
+/// until a human re-opens it (§7.1).
pub fn rejected_before_in(tx: &Transaction<'_>, pkgbase_id: i64, identity_hash: &str) -> Result<bool> {
Ok(tx
.query_row(
@@ -362,7 +348,7 @@ pub fn mark_viewed(db: &Db, id: i64) -> Result<()> {
})
}
-/// §7.1: a rejection can be re-opened. We retire the rejected row so it stops
+/// §7.1: a rejection can be re-opened. The rejected row is retired so it stops
/// suppressing the identity, and the next detection opens a fresh review.
pub fn reopen_rejected(db: &Db, id: i64) -> Result<()> {
let at = time::now();