Skip to content

Commit 168260b

Browse files
committed
Pr Feedback; Remove un-needed items from RETURNING, don't update benchmark_request status, use string constants rather than the enum for setting the status strings
1 parent 296f585 commit 168260b

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

database/src/pool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ mod tests {
716716
.await;
717717
}
718718

719+
#[tokio::test]
719720
async fn get_collector_config_error_if_not_exist() {
720721
run_postgres_test(|ctx| async {
721722
let db = ctx.db_client().connection().await;

database/src/pool/postgres.rs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use crate::{
55
BenchmarkRequest, BenchmarkRequestIndex, BenchmarkRequestStatus, BenchmarkRequestType,
66
BenchmarkSet, CodegenBackend, CollectionId, CollectorConfig, Commit, CommitType,
77
CompileBenchmark, Date, Index, Profile, QueuedCommit, Scenario, Target,
8-
BENCHMARK_JOB_STATUS_IN_PROGRESS_STR, BENCHMARK_REQUEST_MASTER_STR,
9-
BENCHMARK_REQUEST_RELEASE_STR, BENCHMARK_REQUEST_STATUS_ARTIFACTS_READY_STR,
10-
BENCHMARK_REQUEST_STATUS_COMPLETED_STR, BENCHMARK_REQUEST_STATUS_IN_PROGRESS_STR,
11-
BENCHMARK_REQUEST_TRY_STR,
8+
BENCHMARK_JOB_STATUS_IN_PROGRESS_STR, BENCHMARK_JOB_STATUS_QUEUED_STR,
9+
BENCHMARK_REQUEST_MASTER_STR, BENCHMARK_REQUEST_RELEASE_STR,
10+
BENCHMARK_REQUEST_STATUS_ARTIFACTS_READY_STR, BENCHMARK_REQUEST_STATUS_COMPLETED_STR,
11+
BENCHMARK_REQUEST_STATUS_IN_PROGRESS_STR, BENCHMARK_REQUEST_TRY_STR,
1212
};
1313
use anyhow::Context as _;
1414
use chrono::{DateTime, TimeZone, Utc};
@@ -1841,36 +1841,23 @@ where
18411841
WHERE
18421842
job_queue.id = picked.id
18431843
RETURNING
1844-
job_queue.target,
18451844
job_queue.backend,
18461845
job_queue.profile,
18471846
job_queue.request_tag,
1848-
job_queue.benchmark_set,
18491847
job_queue.created_at,
1850-
job_queue.status,
18511848
job_queue.started_at,
18521849
job_queue.retry
1853-
), updated_request AS (
1854-
UPDATE
1855-
benchmark_request
1856-
SET
1857-
status = $6
1858-
FROM
1859-
updated_queue
1860-
WHERE
1861-
updated_queue.request_tag = benchmark_request.tag
18621850
)
18631851
SELECT
18641852
*
18651853
FROM
18661854
updated_queue;",
18671855
&[
1868-
&BenchmarkJobStatus::Queued,
1856+
&BENCHMARK_JOB_STATUS_QUEUED_STR,
18691857
&target,
18701858
&(benchmark_set.0 as i32),
18711859
&collector_name,
18721860
&BENCHMARK_JOB_STATUS_IN_PROGRESS_STR,
1873-
&BenchmarkRequestStatus::InProgress,
18741861
],
18751862
)
18761863
.await?;
@@ -1879,21 +1866,20 @@ where
18791866
None => Ok(None),
18801867
Some(row) => {
18811868
let job = BenchmarkJob {
1882-
target: Target::from_str(&row.get::<_, String>(0))
1883-
.map_err(|e| anyhow::anyhow!(e))?,
1884-
backend: CodegenBackend::from_str(&row.get::<_, String>(1))
1869+
target: *target,
1870+
backend: CodegenBackend::from_str(&row.get::<_, String>(0))
18851871
.map_err(|e| anyhow::anyhow!(e))?,
1886-
profile: Profile::from_str(&row.get::<_, String>(2))
1872+
profile: Profile::from_str(&row.get::<_, String>(1))
18871873
.map_err(|e| anyhow::anyhow!(e))?,
1888-
request_tag: row.get::<_, String>(3),
1889-
benchmark_set: BenchmarkSet(row.get::<_, i32>(4) as u32),
1890-
created_at: row.get::<_, DateTime<Utc>>(5),
1874+
request_tag: row.get::<_, String>(2),
1875+
benchmark_set: benchmark_set.clone(),
1876+
created_at: row.get::<_, DateTime<Utc>>(3),
18911877
// The job is now in an in_progress state
18921878
status: BenchmarkJobStatus::InProgress {
1893-
started_at: row.get::<_, DateTime<Utc>>(7),
1879+
started_at: row.get::<_, DateTime<Utc>>(4),
18941880
collector_name: collector_name.into(),
18951881
},
1896-
retry: row.get::<_, i32>(8) as u32,
1882+
retry: row.get::<_, i32>(5) as u32,
18971883
};
18981884
Ok(Some(job))
18991885
}

0 commit comments

Comments
 (0)