11use  crate :: pool:: { Connection ,  ConnectionManager ,  ManagedConnection ,  Transaction } ; 
22use  crate :: selector:: CompileTestCase ; 
33use  crate :: { 
4-     ArtifactCollection ,  ArtifactId ,  ArtifactIdNumber ,  Benchmark ,  BenchmarkJob ,   BenchmarkJobStatus , 
5-     BenchmarkRequest ,   BenchmarkRequestIndex ,   BenchmarkRequestStatus ,   BenchmarkRequestType , 
6-     BenchmarkSet ,   CodegenBackend ,   CollectionId ,   CollectorConfig ,   Commit ,   CommitType , 
7-     CompileBenchmark ,  Date ,  Index ,  Profile ,  QueuedCommit ,   Scenario ,   Target , 
8-     BENCHMARK_JOB_STATUS_FAILURE_STR ,  BENCHMARK_JOB_STATUS_IN_PROGRESS_STR , 
4+     ArtifactCollection ,  ArtifactId ,  ArtifactIdNumber ,  Benchmark ,  BenchmarkJob , 
5+     BenchmarkJobConclusion ,   BenchmarkJobStatus ,   BenchmarkRequest ,   BenchmarkRequestIndex , 
6+     BenchmarkRequestStatus ,   BenchmarkRequestType ,   BenchmarkSet ,   CodegenBackend ,   CollectionId , 
7+     CollectorConfig ,   Commit ,   CommitType ,   CompileBenchmark ,  Date ,  Index ,  Profile ,  QueuedCommit , 
8+     Scenario ,   Target ,   BENCHMARK_JOB_STATUS_FAILURE_STR ,  BENCHMARK_JOB_STATUS_IN_PROGRESS_STR , 
99    BENCHMARK_JOB_STATUS_QUEUED_STR ,  BENCHMARK_JOB_STATUS_SUCCESS_STR , 
1010    BENCHMARK_REQUEST_MASTER_STR ,  BENCHMARK_REQUEST_RELEASE_STR , 
1111    BENCHMARK_REQUEST_STATUS_ARTIFACTS_READY_STR ,  BENCHMARK_REQUEST_STATUS_COMPLETED_STR , 
@@ -1849,6 +1849,7 @@ where
18491849                    WHERE 
18501850                        job_queue.id = picked.id 
18511851                    RETURNING 
1852+                         job_queue.id, 
18521853                        job_queue.backend, 
18531854                        job_queue.profile, 
18541855                        job_queue.request_tag, 
@@ -1874,20 +1875,21 @@ where
18741875            None  => Ok ( None ) , 
18751876            Some ( row)  => { 
18761877                let  job = BenchmarkJob  { 
1878+                     id :  row. get :: < _ ,  i32 > ( 0 )  as  u32 , 
18771879                    target :  * target, 
1878-                     backend :  CodegenBackend :: from_str ( & row. get :: < _ ,  String > ( 0 ) ) 
1880+                     backend :  CodegenBackend :: from_str ( & row. get :: < _ ,  String > ( 1 ) ) 
18791881                        . map_err ( |e| anyhow:: anyhow!( e) ) ?, 
1880-                     profile :  Profile :: from_str ( & row. get :: < _ ,  String > ( 1 ) ) 
1882+                     profile :  Profile :: from_str ( & row. get :: < _ ,  String > ( 2 ) ) 
18811883                        . map_err ( |e| anyhow:: anyhow!( e) ) ?, 
1882-                     request_tag :  row. get :: < _ ,  String > ( 2 ) , 
1884+                     request_tag :  row. get :: < _ ,  String > ( 3 ) , 
18831885                    benchmark_set :  benchmark_set. clone ( ) , 
1884-                     created_at :  row. get :: < _ ,  DateTime < Utc > > ( 3 ) , 
1886+                     created_at :  row. get :: < _ ,  DateTime < Utc > > ( 4 ) , 
18851887                    // The job is now in an in_progress state 
18861888                    status :  BenchmarkJobStatus :: InProgress  { 
1887-                         started_at :  row. get :: < _ ,  DateTime < Utc > > ( 4 ) , 
1889+                         started_at :  row. get :: < _ ,  DateTime < Utc > > ( 5 ) , 
18881890                        collector_name :  collector_name. into ( ) , 
18891891                    } , 
1890-                     retry :  row. get :: < _ ,  i32 > ( 5 )  as  u32 , 
1892+                     retry :  row. get :: < _ ,  i32 > ( 6 )  as  u32 , 
18911893                } ; 
18921894                Ok ( Some ( job) ) 
18931895            } 
@@ -1949,40 +1951,24 @@ where
19491951
19501952    async  fn  mark_benchmark_job_as_completed ( 
19511953        & self , 
1952-         request_tag :  & str , 
1953-         benchmark_set :  u32 , 
1954-         target :  & Target , 
1955-         status :  & BenchmarkJobStatus , 
1954+         id :  u32 , 
1955+         benchmark_job_conclusion :  & BenchmarkJobConclusion , 
19561956    )  -> anyhow:: Result < ( ) >  { 
1957-         match  status { 
1958-             BenchmarkJobStatus :: Queued  | BenchmarkJobStatus :: InProgress  {  .. }  => { 
1959-                 panic ! ( "Can only mark a job as complete" ) 
1960-             } 
1961-             BenchmarkJobStatus :: Completed  {  success,  .. }  => { 
1962-                 let  status = if  * success { 
1963-                     BENCHMARK_JOB_STATUS_SUCCESS_STR 
1964-                 }  else  { 
1965-                     BENCHMARK_JOB_STATUS_FAILURE_STR 
1966-                 } ; 
1967-                 self . conn ( ) 
1968-                     . execute ( 
1969-                         " 
1970-                         UPDATE 
1971-                             job_queue  
1972-                         SET 
1973-                             status = $1, 
1974-                             completed_at = NOW() 
1975-                         WHERE 
1976-                             request_tag = $2 
1977-                             AND benchmark_set = $3 
1978-                             AND target = $4" , 
1979-                         & [ & status,  & request_tag,  & ( benchmark_set as  i32 ) ,  & target] , 
1980-                     ) 
1981-                     . await 
1982-                     . context ( "Failed to mark benchmark job as completed" ) ?; 
1983-                 Ok ( ( ) ) 
1984-             } 
1985-         } 
1957+         self . conn ( ) 
1958+             . execute ( 
1959+                 " 
1960+                 UPDATE 
1961+                     job_queue  
1962+                 SET 
1963+                     status = $1, 
1964+                     completed_at = NOW() 
1965+                 WHERE 
1966+                     id = $2" , 
1967+                 & [ & benchmark_job_conclusion. as_str ( ) ,  & ( id as  i32 ) ] , 
1968+             ) 
1969+             . await 
1970+             . context ( "Failed to mark benchmark job as completed" ) ?; 
1971+         Ok ( ( ) ) 
19861972    } 
19871973} 
19881974
0 commit comments