@@ -381,6 +381,9 @@ static MIGRATIONS: &[&str] = &[
381
381
r#"
382
382
ALTER TABLE benchmark_request ADD COLUMN commit_date TIMESTAMPTZ NULL;
383
383
"# ,
384
+ r#"
385
+ ALTER TABLE benchmark_request ADD COLUMN duration_ms INTEGER NULL;
386
+ "# ,
384
387
] ;
385
388
386
389
#[ async_trait:: async_trait]
@@ -667,7 +670,7 @@ impl PostgresConnection {
667
670
}
668
671
669
672
const BENCHMARK_REQUEST_COLUMNS : & str =
670
- "tag, parent_sha, pr, commit_type, status, created_at, completed_at, backends, profiles, commit_date" ;
673
+ "tag, parent_sha, pr, commit_type, status, created_at, completed_at, backends, profiles, commit_date, duration_ms " ;
671
674
672
675
#[ async_trait:: async_trait]
673
676
impl < P > Connection for P
@@ -1891,7 +1894,14 @@ where
1891
1894
benchmark_request
1892
1895
SET
1893
1896
status = $1,
1894
- completed_at = NOW()
1897
+ completed_at = NOW(),
1898
+ duration_ms = (
1899
+ SELECT (MAX(EXTRACT('epoch' FROM job_queue.completed_at)) -
1900
+ MIN(EXTRACT('epoch' FROM job_queue.started_at))) * 1000 AS duration_ms
1901
+ FROM
1902
+ job_queue
1903
+ WHERE job_queue.request_tag = $2
1904
+ )
1895
1905
WHERE
1896
1906
benchmark_request.tag = $2
1897
1907
AND benchmark_request.status != $1
@@ -2020,22 +2030,6 @@ where
2020
2030
ORDER BY
2021
2031
completed_at
2022
2032
DESC LIMIT {max_completed_requests}
2023
- ), jobs AS (
2024
- SELECT
2025
- completed.tag,
2026
- job_queue.started_at,
2027
- job_queue.completed_at
2028
- FROM
2029
- job_queue
2030
- LEFT JOIN completed ON job_queue.request_tag = completed.tag
2031
- ), stats AS (
2032
- SELECT
2033
- tag,
2034
- MAX(jobs.completed_at - jobs.started_at) AS duration
2035
- FROM
2036
- jobs
2037
- GROUP BY
2038
- tag
2039
2033
), artifacts AS (
2040
2034
SELECT
2041
2035
artifact.id,
@@ -2056,11 +2050,9 @@ where
2056
2050
)
2057
2051
SELECT
2058
2052
completed.*,
2059
- stats.duration::TEXT,
2060
2053
errors.errors AS errors
2061
2054
FROM
2062
2055
completed
2063
- LEFT JOIN stats ON stats.tag = completed.tag
2064
2056
LEFT JOIN errors ON errors.tag = completed.tag;
2065
2057
"
2066
2058
) ;
@@ -2081,19 +2073,16 @@ where
2081
2073
} )
2082
2074
. collect ( ) ;
2083
2075
2084
- let completed_requests: Vec < ( BenchmarkRequest , String , Vec < String > ) > = self
2076
+ let completed_requests: Vec < ( BenchmarkRequest , Vec < String > ) > = self
2085
2077
. conn ( )
2086
2078
. query ( & completed_requests_query, & [ ] )
2087
2079
. await ?
2088
2080
. iter ( )
2089
2081
. map ( |it| {
2090
2082
(
2091
2083
row_to_benchmark_request ( it) ,
2092
- // Duration being a string feels odd, but we don't need to
2093
- // perform any computations on it
2094
- it. get :: < _ , String > ( 10 ) ,
2095
2084
// The errors, if there are none this will be an empty vector
2096
- it. get :: < _ , Vec < String > > ( 11 ) ,
2085
+ it. get :: < _ , Option < Vec < String > > > ( 11 ) . unwrap_or_default ( ) ,
2097
2086
)
2098
2087
} )
2099
2088
. collect ( ) ;
@@ -2217,11 +2206,13 @@ fn row_to_benchmark_request(row: &Row) -> BenchmarkRequest {
2217
2206
let backends = row. get :: < _ , String > ( 7 ) ;
2218
2207
let profiles = row. get :: < _ , String > ( 8 ) ;
2219
2208
let commit_date = row. get :: < _ , Option < DateTime < Utc > > > ( 9 ) ;
2209
+ let duration_ms = row. get :: < _ , Option < i32 > > ( 10 ) ;
2220
2210
2221
2211
let pr = pr. map ( |v| v as u32 ) ;
2222
2212
2223
- let status = BenchmarkRequestStatus :: from_str_and_completion_date ( status, completed_at)
2224
- . expect ( "Invalid BenchmarkRequestStatus data in the database" ) ;
2213
+ let status =
2214
+ BenchmarkRequestStatus :: from_str_and_completion_date ( status, completed_at, duration_ms)
2215
+ . expect ( "Invalid BenchmarkRequestStatus data in the database" ) ;
2225
2216
2226
2217
match commit_type {
2227
2218
BENCHMARK_REQUEST_TRY_STR => BenchmarkRequest {
0 commit comments