Skip to content

Commit 723deb5

Browse files
committed
Add constants for benchmark request type strings
1 parent f0d1077 commit 723deb5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

database/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,10 @@ impl<'a> tokio_postgres::types::FromSql<'a> for BenchmarkRequestStatus {
849849
}
850850
}
851851

852+
const BENCHMARK_REQUEST_TRY_STR: &str = "try";
853+
const BENCHMARK_REQUEST_MASTER_STR: &str = "master";
854+
const BENCHMARK_REQUEST_RELEASE_STR: &str = "release";
855+
852856
#[derive(Debug, Clone, PartialEq)]
853857
pub enum BenchmarkRequestType {
854858
/// A Try commit
@@ -870,9 +874,9 @@ pub enum BenchmarkRequestType {
870874
impl fmt::Display for BenchmarkRequestType {
871875
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
872876
match self {
873-
BenchmarkRequestType::Try { .. } => write!(f, "try"),
874-
BenchmarkRequestType::Master { .. } => write!(f, "master"),
875-
BenchmarkRequestType::Release { .. } => write!(f, "release"),
877+
BenchmarkRequestType::Try { .. } => write!(f, "{BENCHMARK_REQUEST_TRY_STR}"),
878+
BenchmarkRequestType::Master { .. } => write!(f, "{BENCHMARK_REQUEST_MASTER_STR}"),
879+
BenchmarkRequestType::Release { .. } => write!(f, "{BENCHMARK_REQUEST_RELEASE_STR}"),
876880
}
877881
}
878882
}

database/src/pool/postgres.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
ArtifactCollection, ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkRequest,
44
BenchmarkRequestStatus, BenchmarkRequestType, CodegenBackend, CollectionId, Commit, CommitType,
55
CompileBenchmark, Date, Index, Profile, QueuedCommit, Scenario, Target,
6+
BENCHMARK_REQUEST_MASTER_STR, BENCHMARK_REQUEST_RELEASE_STR, BENCHMARK_REQUEST_TRY_STR,
67
};
78
use anyhow::Context as _;
89
use chrono::{DateTime, TimeZone, Utc};
@@ -1463,7 +1464,7 @@ where
14631464
let profiles = row.get::<_, &str>(8);
14641465

14651466
match commit_type {
1466-
"try" => {
1467+
BENCHMARK_REQUEST_TRY_STR => {
14671468
let mut try_benchmark = BenchmarkRequest::create_try(
14681469
tag,
14691470
parent_sha,
@@ -1476,7 +1477,7 @@ where
14761477
try_benchmark.completed_at = completed_at;
14771478
try_benchmark
14781479
}
1479-
"master" => {
1480+
BENCHMARK_REQUEST_MASTER_STR => {
14801481
let mut master_benchmark = BenchmarkRequest::create_master(
14811482
tag.expect("Master commit in DB without SHA"),
14821483
parent_sha.unwrap(),
@@ -1489,7 +1490,7 @@ where
14891490
master_benchmark.completed_at = completed_at;
14901491
master_benchmark
14911492
}
1492-
"release" => {
1493+
BENCHMARK_REQUEST_RELEASE_STR => {
14931494
let mut release_benchmark = BenchmarkRequest::create_release(
14941495
tag.expect("Release commit in DB witohut SHA"),
14951496
created_at,

0 commit comments

Comments
 (0)