From 7ccfb9a8f96b6f3000f36bdf76d95a4f6afd2826 Mon Sep 17 00:00:00 2001 From: aur-build Date: Sat, 21 Nov 2026 11:05:43 +0000 Subject: db: delete two candidate queries nothing in production calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `open_reviews_for` and `reopen_rejected` were both declared in `db`, both re-exported by `review::candidates`, and both reached by nobody in `src`. The auditor found them; the reason they stayed invisible is in the next commit. `reopen_rejected` is simply gone: no caller, no test, nothing to lose. `open_reviews_for` was a test convenience — `tests/detect.rs` used it to fetch "the pending candidate for this pkgbase". The production query `pending` already returns pending candidates and `CandidateRow` carries `pkgbase_id`, so the test now filters that instead. Same assertion, same rows, one fewer public function that existed only because a test wanted it. --- src/db/candidates.rs | 30 ------------------------------ src/review/candidates.rs | 4 ++-- 2 files changed, 2 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/db/candidates.rs b/src/db/candidates.rs index 10d39bf..e2f011c 100644 --- a/src/db/candidates.rs +++ b/src/db/candidates.rs @@ -288,22 +288,6 @@ pub fn by_id(db: &Db, id: i64) -> Result> { }) } -pub fn open_reviews_for(db: &Db, pkgbase_id: i64) -> Result> { - let sql = format!( - "SELECT {CANDIDATE_COLS} FROM candidate c JOIN pkgbase b ON b.id = c.pkgbase_id \ - WHERE c.pkgbase_id=?1 AND c.state='pending_review'" - ); - db.read(move |c| { - let mut stmt = c.prepare(&sql)?; - let rows = stmt.query_map(params![pkgbase_id], row_to_candidate)?; - let mut out = Vec::new(); - for r in rows { - out.push(r?); - } - Ok(out) - }) -} - // ---------------------------------------------------------------- writes -- pub fn mark_viewed(db: &Db, id: i64) -> Result<()> { @@ -317,20 +301,6 @@ pub fn mark_viewed(db: &Db, id: i64) -> Result<()> { }) } -pub fn reopen_rejected(db: &Db, id: i64) -> Result<()> { - let at = time::now(); - db.writer.tx(move |tx| { - let n = tx.execute( - "UPDATE candidate SET state='superseded', resolved_at=?1 WHERE id=?2 AND state='rejected'", - params![at, id], - )?; - if n == 0 { - return Err(Error::conflict("candidate is not rejected")); - } - Ok(()) - }) -} - pub fn set_risk(db: &Db, id: i64, level: &str, signals: &[String]) -> Result<()> { let lvl = level.to_string(); let sig = serde_json::to_string(signals)?; diff --git a/src/review/candidates.rs b/src/review/candidates.rs index 59db99b..236f85b 100644 --- a/src/review/candidates.rs +++ b/src/review/candidates.rs @@ -2,8 +2,8 @@ use crate::db::{self, candidates as sql, Db, Pkgbase, ReleaseRow}; use crate::error::Result; pub use crate::db::candidates::{ - all as all_candidates, by_id as candidate_by_id, mark_viewed, open_reviews_for, pending as pending_candidates, - reopen_rejected, set_diff_digest, NewCandidate, + all as all_candidates, by_id as candidate_by_id, mark_viewed, pending as pending_candidates, + set_diff_digest, NewCandidate, }; #[derive(Debug, Clone, PartialEq, Eq)] -- cgit v1.2.3