Skip to content

Commit 10904fc

Browse files
committed
Create dedicated function for creating try requests without artifacts
1 parent 8d404d4 commit 10904fc

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

database/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,6 @@ impl fmt::Display for BenchmarkRequestStatus {
852852
}
853853
}
854854

855-
856-
857855
const BENCHMARK_REQUEST_TRY_STR: &str = "try";
858856
const BENCHMARK_REQUEST_MASTER_STR: &str = "master";
859857
const BENCHMARK_REQUEST_RELEASE_STR: &str = "release";
@@ -912,23 +910,21 @@ impl BenchmarkRequest {
912910
}
913911
}
914912

915-
pub fn create_try(
916-
sha: Option<&str>,
917-
parent_sha: Option<&str>,
913+
/// Create a try request that is waiting for artifacts
914+
pub fn create_try_without_artifacts(
918915
pr: u32,
919916
created_at: DateTime<Utc>,
920-
status: BenchmarkRequestStatus,
921917
backends: &str,
922918
profiles: &str,
923919
) -> Self {
924920
Self {
925921
commit_type: BenchmarkRequestType::Try {
926922
pr,
927-
sha: sha.map(|it| it.to_string()),
928-
parent_sha: parent_sha.map(|it| it.to_string()),
923+
sha: None,
924+
parent_sha: None,
929925
},
930926
created_at,
931-
status,
927+
status: BenchmarkRequestStatus::WaitingForArtifacts,
932928
backends: backends.to_string(),
933929
profiles: profiles.to_string(),
934930
}

site/src/request_handlers/github.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::github::{
66
use crate::job_queue::run_new_queue;
77
use crate::load::SiteCtxt;
88

9-
use database::{BenchmarkRequest, BenchmarkRequestStatus};
9+
use database::BenchmarkRequest;
1010
use hashbrown::HashMap;
1111
use std::sync::Arc;
1212

@@ -74,25 +74,18 @@ async fn handle_issue(
7474
Ok(github::Response)
7575
}
7676

77-
/// The try does not have a `sha` or a `parent_sha` but we need to keep a record
78-
/// of this commit existing. We make sure there can only be one `pr` with a
79-
/// status of `WaitingForArtifacts` to ensure we don't have duplicates.
80-
async fn queue_partial_try_benchmark_request(
77+
/// The try request does not have a `sha` or a `parent_sha` but we need to keep a record
78+
/// of this commit existing. The DB ensures that there is only one non-completed
79+
/// try benchmark request per `pr`.
80+
async fn record_try_benchmark_request_without_artifacts(
8181
conn: &dyn database::pool::Connection,
8282
pr: u32,
8383
backends: &str,
8484
) {
8585
// We only want to run this if the new system is running
8686
if run_new_queue() {
87-
let try_request = BenchmarkRequest::create_try(
88-
None,
89-
None,
90-
pr,
91-
chrono::Utc::now(),
92-
BenchmarkRequestStatus::WaitingForArtifacts,
93-
backends,
94-
"",
95-
);
87+
let try_request =
88+
BenchmarkRequest::create_try_without_artifacts(pr, chrono::Utc::now(), backends, "");
9689
if let Err(e) = conn.insert_benchmark_request(&try_request).await {
9790
log::error!("Failed to insert try benchmark request: {}", e);
9891
}
@@ -125,7 +118,7 @@ async fn handle_rust_timer(
125118
Ok(cmd) => {
126119
let conn = ctxt.conn().await;
127120

128-
queue_partial_try_benchmark_request(
121+
record_try_benchmark_request_without_artifacts(
129122
&*conn,
130123
issue.number,
131124
cmd.params.backends.unwrap_or(""),
@@ -171,7 +164,7 @@ async fn handle_rust_timer(
171164
{
172165
let conn = ctxt.conn().await;
173166
for command in &valid_build_cmds {
174-
queue_partial_try_benchmark_request(
167+
record_try_benchmark_request_without_artifacts(
175168
&*conn,
176169
issue.number,
177170
command.params.backends.unwrap_or(""),

0 commit comments

Comments
 (0)