Skip to content

Commit 5eb02b8

Browse files
committed
PR Feedback; correct gramma & make targets not an Option
1 parent 4859212 commit 5eb02b8

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

database/schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Columns:
276276
* `completed`: Completed request.
277277
* **backends** (`text NOT NULL`): Comma-separated list of codegen backends to benchmark. If empty, the default set of codegen backends will be benchmarked.
278278
* **profiles** (`text NOT NULL`): Comma-separated list of profiles to benchmark. If empty, the default set of profiles will be benchmarked.
279-
* **targets** (`text NOT NULL`): Comma-separated list of targets to benchmark. If empty, the default `x86_64-unknown-linux-gnu` be benchmarked.
279+
* **targets** (`text NOT NULL`): Comma-separated list of targets to benchmark. If empty, the default `x86_64-unknown-linux-gnu` will be benchmarked.
280280

281281
### collector_config
282282

database/src/lib.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ pub struct BenchmarkRequest {
921921
status: BenchmarkRequestStatus,
922922
backends: String,
923923
profiles: String,
924-
targets: Option<String>,
924+
targets: String,
925925
}
926926

927927
impl BenchmarkRequest {
@@ -936,7 +936,7 @@ impl BenchmarkRequest {
936936
status: BenchmarkRequestStatus::ArtifactsReady,
937937
backends: String::new(),
938938
profiles: String::new(),
939-
targets: None,
939+
targets: String::new(),
940940
}
941941
}
942942

@@ -958,7 +958,7 @@ impl BenchmarkRequest {
958958
status: BenchmarkRequestStatus::WaitingForArtifacts,
959959
backends: backends.to_string(),
960960
profiles: profiles.to_string(),
961-
targets: Some(targets.to_string()),
961+
targets: targets.to_string(),
962962
}
963963
}
964964

@@ -975,7 +975,7 @@ impl BenchmarkRequest {
975975
status: BenchmarkRequestStatus::ArtifactsReady,
976976
backends: String::new(),
977977
profiles: String::new(),
978-
targets: None,
978+
targets: String::new(),
979979
}
980980
}
981981

@@ -1056,14 +1056,11 @@ impl BenchmarkRequest {
10561056

10571057
/// Get the targets for the request
10581058
pub fn targets(&self) -> anyhow::Result<Vec<Target>> {
1059-
if let Some(targets) = &self.targets {
1060-
if targets.trim().is_empty() {
1061-
return Ok(Target::default_targets());
1062-
}
1063-
parse_targets(targets).map_err(|e| anyhow::anyhow!("{e}"))
1064-
} else {
1065-
Ok(Target::default_targets())
1059+
if self.targets.trim().is_empty() {
1060+
return Ok(Target::default_targets());
10661061
}
1062+
1063+
parse_targets(&self.targets).map_err(|e| anyhow::anyhow!("{e}"))
10671064
}
10681065

10691066
pub fn is_completed(&self) -> bool {
@@ -1085,7 +1082,7 @@ pub enum BenchmarkRequestInsertResult {
10851082
NothingInserted,
10861083
}
10871084

1088-
fn parse_raw_string<T>(raw_string: &str, name: &str) -> Result<Vec<T>, String>
1085+
fn parse_comma_separated<T>(raw_string: &str, name: &str) -> Result<Vec<T>, String>
10891086
where
10901087
T: FromStr,
10911088
{
@@ -1096,15 +1093,15 @@ where
10961093
}
10971094

10981095
pub fn parse_backends(backends: &str) -> Result<Vec<CodegenBackend>, String> {
1099-
parse_raw_string(backends, "backend")
1096+
parse_comma_separated(backends, "backend")
11001097
}
11011098

11021099
pub fn parse_profiles(profiles: &str) -> Result<Vec<Profile>, String> {
1103-
parse_raw_string(profiles, "profile")
1100+
parse_comma_separated(profiles, "profile")
11041101
}
11051102

11061103
pub fn parse_targets(targets: &str) -> Result<Vec<Target>, String> {
1107-
parse_raw_string(targets, "target")
1104+
parse_comma_separated(targets, "target")
11081105
}
11091106

11101107
/// Cached information about benchmark requests in the DB

database/src/pool/postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ fn row_to_benchmark_request(row: &Row, row_offset: Option<usize>) -> BenchmarkRe
23512351
let profiles = row.get::<_, String>(8 + row_offset);
23522352
let commit_date = row.get::<_, Option<DateTime<Utc>>>(9 + row_offset);
23532353
let duration_ms = row.get::<_, Option<i32>>(10 + row_offset);
2354-
let targets = row.get::<_, Option<String>>(11 + row_offset);
2354+
let targets = row.get::<_, String>(11 + row_offset);
23552355

23562356
let pr = pr.map(|v| v as u32);
23572357

0 commit comments

Comments
 (0)