@@ -13,7 +13,6 @@ use std::str::FromStr;
1313use std:: sync:: Arc ;
1414use std:: time:: Duration ;
1515use tokio:: sync:: Mutex ;
16- use tokio_postgres:: types:: { FromSql , Type } ;
1716use tokio_postgres:: GenericClient ;
1817use tokio_postgres:: Statement ;
1918
@@ -1418,11 +1417,10 @@ where
14181417 async fn get_benchmark_requests_by_status (
14191418 & self ,
14201419 statuses : & [ BenchmarkRequestStatus ] ,
1421- days : Option < i32 > ,
14221420 ) -> anyhow:: Result < Vec < BenchmarkRequest > > {
14231421 // There is a small period of time where a try commit's parent_sha
14241422 // could be NULL, this query will filter that out.
1425- let mut query = "
1423+ let query = "
14261424 SELECT
14271425 tag,
14281426 parent_sha,
@@ -1438,22 +1436,16 @@ where
14381436 AND (commit_type <> 'try' OR parent_sha IS NOT NULL) "
14391437 . to_string ( ) ;
14401438
1441- // Optionally add interval
1442- let rows = if let Some ( days) = days {
1443- // postgres expects the interval to be a `float` so we cast with;
1444- // `::INT`, we can't do; `INTERVAL '$2 day'` which, while looking
1445- // natural is invalid.
1446- query += "AND created_at > current_date - $2::INT * INTERVAL '1 day'" ;
1447- self . conn ( ) . query ( & query, & [ & statuses, & days] ) . await
1448- } else {
1449- self . conn ( ) . query ( & query, & [ & statuses] ) . await
1450- }
1451- . context ( "Failed to get benchmark requests" ) ?;
1439+ let rows = self
1440+ . conn ( )
1441+ . query ( & query, & [ & statuses] )
1442+ . await
1443+ . context ( "Failed to get benchmark requests" ) ?;
14521444
14531445 let benchmark_requests = rows
14541446 . iter ( )
14551447 . map ( |row| {
1456- let tag = row. get :: < _ , String > ( 0 ) ;
1448+ let tag = row. get :: < _ , & str > ( 0 ) ;
14571449 let parent_sha = row. get :: < _ , Option < String > > ( 1 ) ;
14581450 let pr = row. get :: < _ , Option < i32 > > ( 2 ) ;
14591451 let commit_type = row. get :: < _ , String > ( 3 ) ;
@@ -1466,7 +1458,7 @@ where
14661458 match commit_type. as_str ( ) {
14671459 "try" => {
14681460 let mut try_benchmark = BenchmarkRequest :: create_try (
1469- & tag,
1461+ tag,
14701462 & parent_sha. unwrap ( ) ,
14711463 pr. unwrap ( ) as u32 ,
14721464 created_at,
@@ -1479,7 +1471,7 @@ where
14791471 }
14801472 "master" => {
14811473 let mut master_benchmark = BenchmarkRequest :: create_master (
1482- & tag,
1474+ tag,
14831475 & parent_sha. unwrap ( ) ,
14841476 pr. unwrap ( ) as u32 ,
14851477 created_at,
@@ -1492,7 +1484,7 @@ where
14921484 }
14931485 "release" => {
14941486 let mut release_benchmark = BenchmarkRequest :: create_release (
1495- & tag, created_at, status, & backends, & profiles,
1487+ tag, created_at, status, & backends, & profiles,
14961488 ) ;
14971489 release_benchmark. completed_at = completed_at;
14981490 release_benchmark
@@ -1575,28 +1567,6 @@ macro_rules! impl_to_postgresql_via_to_string {
15751567impl_to_postgresql_via_to_string ! ( BenchmarkRequestType ) ;
15761568impl_to_postgresql_via_to_string ! ( BenchmarkRequestStatus ) ;
15771569
1578- impl < ' a > FromSql < ' a > for BenchmarkRequestStatus {
1579- fn from_sql (
1580- ty : & Type ,
1581- raw : & ' a [ u8 ] ,
1582- ) -> Result < Self , Box < dyn std:: error:: Error + Sync + Send > > {
1583- // Decode raw bytes into &str with Postgres' own text codec
1584- let s: & str = <& str as FromSql >:: from_sql ( ty, raw) ?;
1585-
1586- match s {
1587- "waiting_for_artifacts" => Ok ( Self :: WaitingForArtifacts ) ,
1588- "artifacts_ready" => Ok ( Self :: ArtifactsReady ) ,
1589- "in_progress" => Ok ( Self :: InProgress ) ,
1590- "completed" => Ok ( Self :: Completed ) ,
1591- other => Err ( format ! ( "unknown benchmark_request_status '{other}'" ) . into ( ) ) ,
1592- }
1593- }
1594-
1595- fn accepts ( ty : & Type ) -> bool {
1596- <& str as FromSql >:: accepts ( ty)
1597- }
1598- }
1599-
16001570#[ cfg( test) ]
16011571mod tests {
16021572 use super :: make_certificates;
0 commit comments