Skip to content

Commit 497cde5

Browse files
committed
PR Feedback: rename enum variants and update messages
1 parent 66c001d commit 497cde5

File tree

5 files changed

+24
-31
lines changed

5 files changed

+24
-31
lines changed

database/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ impl BenchmarkRequest {
10411041

10421042
#[derive(Debug, Clone, PartialEq)]
10431043
pub enum BenchmarkRequestInsertResult {
1044-
Queued,
1045-
AlreadyQueued,
1044+
Inserted,
1045+
NothingInserted,
10461046
}
10471047

10481048
pub fn parse_backends(backends: &str) -> Result<Vec<CodegenBackend>, String> {

database/src/pool.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,10 @@ mod tests {
543543
.await;
544544

545545
assert!(result.is_ok());
546-
assert_eq!(result.unwrap(), BenchmarkRequestInsertResult::AlreadyQueued);
546+
assert_eq!(
547+
result.unwrap(),
548+
BenchmarkRequestInsertResult::NothingInserted
549+
);
547550

548551
Ok(ctx)
549552
})
@@ -576,7 +579,7 @@ mod tests {
576579
.await
577580
.unwrap();
578581

579-
assert_eq!(result, BenchmarkRequestInsertResult::AlreadyQueued);
582+
assert_eq!(result, BenchmarkRequestInsertResult::NothingInserted);
580583
Ok(ctx)
581584
})
582585
.await;
@@ -607,7 +610,7 @@ mod tests {
607610
.await
608611
.unwrap();
609612

610-
assert_eq!(result, BenchmarkRequestInsertResult::AlreadyQueued);
613+
assert_eq!(result, BenchmarkRequestInsertResult::NothingInserted);
611614

612615
Ok(ctx)
613616
})

database/src/pool/postgres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,9 +1670,9 @@ where
16701670
if rows.is_empty() {
16711671
// Allows us to handle duplicated cases without the database auto
16721672
// erroring
1673-
Ok(BenchmarkRequestInsertResult::AlreadyQueued)
1673+
Ok(BenchmarkRequestInsertResult::NothingInserted)
16741674
} else {
1675-
Ok(BenchmarkRequestInsertResult::Queued)
1675+
Ok(BenchmarkRequestInsertResult::Inserted)
16761676
}
16771677
}
16781678

site/src/job_queue/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ async fn create_benchmark_request_master_commits(
5656
log::info!("Inserting master benchmark request {benchmark:?}");
5757

5858
match conn.insert_benchmark_request(&benchmark).await {
59-
Ok(BenchmarkRequestInsertResult::AlreadyQueued) => {
59+
Ok(BenchmarkRequestInsertResult::NothingInserted) => {
6060
log::error!(
6161
"Failed to insert master benchmark request, request for PR`#{pr}` already exists",
6262
);
6363
}
64-
Ok(BenchmarkRequestInsertResult::Queued) => {}
64+
Ok(BenchmarkRequestInsertResult::Inserted) => {}
6565
Err(e) => {
6666
log::error!("Failed to insert master benchmark request: {e:?}");
6767
}
@@ -95,12 +95,12 @@ async fn create_benchmark_request_releases(
9595
log::info!("Inserting release benchmark request {release_request:?}");
9696

9797
match conn.insert_benchmark_request(&release_request).await {
98-
Ok(BenchmarkRequestInsertResult::AlreadyQueued) => {
98+
Ok(BenchmarkRequestInsertResult::NothingInserted) => {
9999
log::error!(
100100
"Failed to insert release benchmark request, release with tag `{name}` already exists"
101101
);
102102
}
103-
Ok(BenchmarkRequestInsertResult::Queued) => {}
103+
Ok(BenchmarkRequestInsertResult::Inserted) => {}
104104
Err(e) => {
105105
log::error!("Failed to insert release benchmark request: {e}");
106106
}

site/src/request_handlers/github.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,26 @@ fn get_awaiting_on_bors_message() -> String {
9090
/// of this commit existing. The DB ensures that there is only one non-completed
9191
/// try benchmark request per `pr`.
9292
async fn record_try_benchmark_request_without_artifacts(
93-
client: &client::Client,
9493
conn: &dyn database::pool::Connection,
9594
pr: u32,
9695
backends: &str,
97-
) -> ServerResult<github::Response> {
96+
) -> String {
9897
let try_request = BenchmarkRequest::create_try_without_artifacts(pr, backends, "");
9998
log::info!("Inserting try benchmark request {try_request:?}");
10099

101100
match conn.insert_benchmark_request(&try_request).await {
102-
Ok(BenchmarkRequestInsertResult::AlreadyQueued) => {
103-
log::error!(
101+
Ok(BenchmarkRequestInsertResult::NothingInserted) => {
102+
log::info!(
104103
"Failed to insert try benchmark request, a request for PR`#{pr}` already exists"
105104
);
106-
client.post_comment(pr, format!("Failed to insert try benchmark request, a request for PR`#{pr}` already exists")).await;
107-
}
108-
Ok(BenchmarkRequestInsertResult::Queued) => {
109-
client
110-
.post_comment(pr, get_awaiting_on_bors_message())
111-
.await;
105+
format!("This pull request was already queued before and is awaiting a try build to finish.")
112106
}
107+
Ok(BenchmarkRequestInsertResult::Inserted) => get_awaiting_on_bors_message(),
113108
Err(e) => {
114109
log::error!("Failed to insert release benchmark request: {e}");
115-
client
116-
.post_comment(pr, "Something went wrong! This is most likely an internal failure, please message on Zulip".to_string())
117-
.await;
110+
"Something went wrong! This is most likely an internal failure, please let us know on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/247081-t-compiler.2Fperformance)".to_string()
118111
}
119112
}
120-
Ok(github::Response)
121113
}
122114

123115
async fn handle_rust_timer(
@@ -152,13 +144,12 @@ async fn handle_rust_timer(
152144
let conn = ctxt.conn().await;
153145

154146
if should_use_job_queue(issue.number) {
155-
return record_try_benchmark_request_without_artifacts(
156-
main_client,
147+
record_try_benchmark_request_without_artifacts(
157148
&*conn,
158149
issue.number,
159150
cmd.params.backends.unwrap_or(""),
160151
)
161-
.await;
152+
.await
162153
} else {
163154
conn.queue_pr(
164155
issue.number,
@@ -168,8 +159,8 @@ async fn handle_rust_timer(
168159
cmd.params.backends,
169160
)
170161
.await;
162+
get_awaiting_on_bors_message()
171163
}
172-
get_awaiting_on_bors_message()
173164
}
174165
Err(error) => {
175166
format!("Error occurred while parsing comment: {error}")
@@ -201,8 +192,7 @@ async fn handle_rust_timer(
201192
let conn = ctxt.conn().await;
202193
for command in &valid_build_cmds {
203194
if should_use_job_queue(issue.number) {
204-
return record_try_benchmark_request_without_artifacts(
205-
main_client,
195+
record_try_benchmark_request_without_artifacts(
206196
&*conn,
207197
issue.number,
208198
command.params.backends.unwrap_or(""),

0 commit comments

Comments
 (0)