Skip to content

Commit

Permalink
review-check: Allow setting the check results
Browse files Browse the repository at this point in the history
This field is intended for a machine-readable description of the check's
original results (separate from the status reason, which may change when
the check is reviewed).
  • Loading branch information
jameswestman authored and barthalion committed Jun 21, 2023
1 parent dc67a84 commit a1f4d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async fn get_job_async(
#[serde(rename_all = "kebab-case")]
pub struct ReviewArgs {
new_status: CheckStatus,
new_results: Option<String>,
}

pub fn review_check(
Expand All @@ -79,7 +80,7 @@ async fn review_check_async(
) -> Result<HttpResponse, ApiError> {
req.has_token_claims("build", ClaimsScope::ReviewCheck)?;

db.set_check_status(params.id, args.new_status.clone())
db.set_check_status(params.id, args.new_status.clone(), args.new_results.clone())
.await?;

let check = db.get_check_by_job_id(params.id).await?;
Expand Down
8 changes: 7 additions & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,19 @@ impl Db {
&self,
job: i32,
new_status: CheckStatus,
new_results: Option<String>,
) -> Result<(), ApiError> {
self.run(move |conn| {
use schema::checks::dsl;
let (status, status_reason) = new_status.to_db();

diesel::update(dsl::checks)
.filter(dsl::job_id.eq(job))
.set((dsl::status.eq(status), dsl::status_reason.eq(status_reason)))
.set((
dsl::status.eq(status),
dsl::status_reason.eq(status_reason),
new_results.map(|r| dsl::results.eq(r)),
))
.execute(conn)?;
Ok(())
})
Expand Down

0 comments on commit a1f4d2f

Please sign in to comment.