Skip to content

Commit 1acbb5b

Browse files
committed
make master commit parent_sha Nullable
1 parent f814e55 commit 1acbb5b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

database/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ pub enum BenchmarkRequestType {
872872
/// A Master commit
873873
Master {
874874
sha: String,
875-
parent_sha: String,
875+
parent_sha: Option<String>,
876876
pr: u32,
877877
},
878878
/// A release only has a tag
@@ -937,7 +937,7 @@ impl BenchmarkRequest {
937937
commit_type: BenchmarkRequestType::Master {
938938
pr,
939939
sha: sha.to_string(),
940-
parent_sha: parent_sha.to_string(),
940+
parent_sha: Some(parent_sha.to_string()),
941941
},
942942
commit_date: Some(commit_date),
943943
created_at: Utc::now(),
@@ -968,8 +968,8 @@ impl BenchmarkRequest {
968968

969969
pub fn parent_sha(&self) -> Option<&str> {
970970
match &self.commit_type {
971-
BenchmarkRequestType::Try { parent_sha, .. } => parent_sha.as_deref(),
972-
BenchmarkRequestType::Master { parent_sha, .. } => Some(parent_sha),
971+
BenchmarkRequestType::Try { parent_sha, .. }
972+
| BenchmarkRequestType::Master { parent_sha, .. } => parent_sha.as_deref(),
973973
BenchmarkRequestType::Release { .. } => None,
974974
}
975975
}

database/src/pool/postgres.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,16 +1602,18 @@ where
16021602
// happen as the parent_sha may not be in the range of initial commits
16031603
// we load into the database when the job queue first starts and inserts
16041604
// it's first batch of requests.
1605-
let row = self
1605+
let rows = self
16061606
.conn()
1607-
.query_one(
1607+
.query(
16081608
"SELECT tag FROM benchmark_request WHERE tag = $1",
16091609
&[&benchmark_request.parent_sha()],
16101610
)
16111611
.await
16121612
.context("Failed to check parent sha")?;
16131613

1614-
let parent_sha = row.get::<_, Option<String>>(0).map(|parent_sha| parent_sha);
1614+
let parent_sha = rows
1615+
.first()
1616+
.map(|row| row.get::<_, Option<String>>(0).map(|parent_sha| parent_sha));
16151617

16161618
self.conn()
16171619
.execute(
@@ -2306,7 +2308,7 @@ fn row_to_benchmark_request(row: &Row, row_offset: Option<usize>) -> BenchmarkRe
23062308
BENCHMARK_REQUEST_MASTER_STR => BenchmarkRequest {
23072309
commit_type: BenchmarkRequestType::Master {
23082310
sha: tag.expect("Master commit in the DB without a SHA"),
2309-
parent_sha: parent_sha.expect("Master commit in the DB without a parent SHA"),
2311+
parent_sha,
23102312
pr: pr.expect("Master commit in the DB without a PR"),
23112313
},
23122314
commit_date,

0 commit comments

Comments
 (0)