diff options
Diffstat (limited to 'src/db')
| -rw-r--r-- | src/db/queries.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/db/queries.rs b/src/db/queries.rs index fe3109a..2bbd4c1 100644 --- a/src/db/queries.rs +++ b/src/db/queries.rs @@ -575,6 +575,28 @@ pub fn our_package_names(db: &Db) -> Result<std::collections::BTreeSet<String>> }) } +/// The recipe the accepted release was actually built from, by walking +/// release -> candidate -> snapshot. Risk scoring compares against this, which +/// is why "last seen" can never leak into a review (§6, I2). +pub fn accepted_recipe(db: &Db, release: &ReleaseRow) -> Result<Option<Recipe>> { + let cid = match release.candidate_id { + Some(c) => c, + None => return Ok(None), + }; + db.read(move |c| { + use rusqlite::OptionalExtension; + Ok(c.query_row( + "SELECT s.srcinfo_json FROM snapshot s + JOIN candidate cnd ON cnd.snapshot_id = s.id + WHERE cnd.id = ?1", + params![cid], + |r| r.get::<_, String>(0), + ) + .optional()? + .and_then(|j| serde_json::from_str::<Recipe>(&j).ok())) + }) +} + // --------------------------------------------------------- stage B cache -- /// Exact cache hit: same recipe, same upstream tips (§5.2). |
