summaryrefslogtreecommitdiffstats
path: root/src/review/reads.rs
blob: 0f91f746f5d64855be042c62e00d78f8404dbac6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! Reading review's state without reaching into its tables.
//!
//! The pipeline needs two facts about a candidate: the row itself, and whether
//! a human approved it. It used to fetch them by calling through review's
//! re-exports of db's query functions, which meant the step machine knew the
//! shape of review's storage. These two calls are the whole of what it needs.

use crate::db::{self, approvals, model::CandidateRow, Db};
use crate::error::Result;

pub fn candidate(db: &Db, id: i64) -> Result<Option<CandidateRow>> {
    db::candidates::by_id(db, id)
}

/// The approval behind a candidate, as `(approval id, decision)`. `None` means
/// no human has decided, which is what publish refuses on.
pub fn approval(db: &Db, candidate_id: i64) -> Result<Option<(i64, String)>> {
    approvals::for_candidate(db, candidate_id)
}