|
1 | 1 | use crate::pool::{Connection, ConnectionManager, ManagedConnection, Transaction}; |
2 | 2 | use crate::{ |
3 | | - ArtifactCollection, ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkRequest, |
4 | | - BenchmarkRequestType, CodegenBackend, CollectionId, Commit, CommitType, CompileBenchmark, Date, |
5 | | - Index, Profile, QueuedCommit, Scenario, Target, |
| 3 | + ArtifactCollection, ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkRequest, CodegenBackend, |
| 4 | + CollectionId, Commit, CommitType, CompileBenchmark, Date, Index, Profile, QueuedCommit, |
| 5 | + Scenario, Target, |
6 | 6 | }; |
7 | 7 | use anyhow::Context as _; |
8 | 8 | use chrono::{DateTime, TimeZone, Utc}; |
@@ -287,20 +287,20 @@ static MIGRATIONS: &[&str] = &[ |
287 | 287 | alter table pstat_series add constraint test_case UNIQUE(crate, profile, scenario, backend, target, metric); |
288 | 288 | "#, |
289 | 289 | r#" |
290 | | - CREATE TABLE IF NOT EXISTS benchmark_requests ( |
| 290 | + CREATE TABLE IF NOT EXISTS benchmark_request ( |
291 | 291 | id SERIAL PRIMARY KEY, |
292 | 292 | tag TEXT NOT NULL UNIQUE, |
293 | 293 | parent_sha TEXT, |
294 | | - commit_type TEXT, |
| 294 | + commit_type TEXT NOT NULL, |
295 | 295 | pr INTEGER, |
296 | 296 | created_at TIMESTAMPTZ NOT NULL, |
297 | 297 | completed_at TIMESTAMPTZ, |
298 | 298 | status TEXT NOT NULL, |
299 | | - backends TEXT, |
300 | | - profiles TEXT |
| 299 | + backends TEXT NOT NULL, |
| 300 | + profiles TEXT NOT NULL |
301 | 301 | ); |
302 | | - CREATE INDEX IF NOT EXISTS benchmark_requests_status_idx on benchmark_requests (status); |
303 | | - CREATE INDEX IF NOT EXISTS benchmark_requests_commit_type on benchmark_requests (commit_type); |
| 302 | + CREATE INDEX IF NOT EXISTS benchmark_request_status_idx on benchmark_request (status); |
| 303 | + CREATE INDEX IF NOT EXISTS benchmark_request_commit_type on benchmark_request (commit_type); |
304 | 304 | "#, |
305 | 305 | ]; |
306 | 306 |
|
@@ -1384,63 +1384,35 @@ where |
1384 | 1384 | } |
1385 | 1385 |
|
1386 | 1386 | async fn insert_benchmark_request(&self, benchmark_request: &BenchmarkRequest) { |
1387 | | - match &benchmark_request.commit_type { |
1388 | | - BenchmarkRequestType::Try { |
1389 | | - sha, |
1390 | | - parent_sha, |
1391 | | - pr, |
1392 | | - } |
1393 | | - | BenchmarkRequestType::Master { |
1394 | | - sha, |
1395 | | - parent_sha, |
1396 | | - pr, |
1397 | | - } => { |
1398 | | - self.conn() |
1399 | | - .execute( |
1400 | | - r#" |
1401 | | - INSERT INTO |
1402 | | - benchmark_requests(parent_sha, pr, tag, created_at, |
1403 | | - commit_type, status, backends, profiles) |
1404 | | - VALUES ($1, $2, $3, $4, $5, $6, $7, $8) |
1405 | | - ON CONFLICT DO NOTHING; |
1406 | | - "#, |
1407 | | - &[ |
1408 | | - &parent_sha, |
1409 | | - pr, |
1410 | | - sha, |
1411 | | - &benchmark_request.created_at, |
1412 | | - &benchmark_request.commit_type.to_string(), |
1413 | | - &benchmark_request.status.to_string(), |
1414 | | - &benchmark_request.backends, |
1415 | | - &benchmark_request.profiles, |
1416 | | - ], |
1417 | | - ) |
1418 | | - .await |
1419 | | - .unwrap(); |
1420 | | - } |
1421 | | - BenchmarkRequestType::Release { tag } => { |
1422 | | - self.conn() |
1423 | | - .execute( |
1424 | | - r#" |
1425 | | - INSERT INTO |
1426 | | - benchmark_requests(tag, created_at, commit_type, |
1427 | | - status, backends, profiles) |
1428 | | - VALUES ($1, $2, $3, $4, $5, $6); |
1429 | | - ON CONFLICT DO NOTHING; |
1430 | | - "#, |
1431 | | - &[ |
1432 | | - tag, |
1433 | | - &benchmark_request.created_at, |
1434 | | - &benchmark_request.commit_type.to_string(), |
1435 | | - &benchmark_request.status.to_string(), |
1436 | | - &benchmark_request.backends, |
1437 | | - &benchmark_request.profiles, |
1438 | | - ], |
1439 | | - ) |
1440 | | - .await |
1441 | | - .unwrap(); |
1442 | | - } |
1443 | | - } |
| 1387 | + self.conn() |
| 1388 | + .execute( |
| 1389 | + r#" |
| 1390 | + INSERT INTO benchmark_request( |
| 1391 | + tag, |
| 1392 | + parent_sha, |
| 1393 | + pr, |
| 1394 | + commit_type, |
| 1395 | + status, |
| 1396 | + created_at, |
| 1397 | + backends, |
| 1398 | + profiles |
| 1399 | + ) |
| 1400 | + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) |
| 1401 | + ON CONFLICT DO NOTHING; |
| 1402 | + "#, |
| 1403 | + &[ |
| 1404 | + &benchmark_request.tag(), |
| 1405 | + &benchmark_request.parent_sha(), |
| 1406 | + &benchmark_request.pr().map(|it| *it as i32), |
| 1407 | + &benchmark_request.commit_type(), |
| 1408 | + &benchmark_request.status.to_string(), |
| 1409 | + &benchmark_request.created_at, |
| 1410 | + &benchmark_request.backends, |
| 1411 | + &benchmark_request.profiles, |
| 1412 | + ], |
| 1413 | + ) |
| 1414 | + .await |
| 1415 | + .unwrap(); |
1444 | 1416 | } |
1445 | 1417 | } |
1446 | 1418 |
|
|
0 commit comments