diff options
Diffstat (limited to 'src/review/reads.rs')
| -rw-r--r-- | src/review/reads.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/review/reads.rs b/src/review/reads.rs new file mode 100644 index 0000000..0f91f74 --- /dev/null +++ b/src/review/reads.rs @@ -0,0 +1,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) +} |
