@@ -3,7 +3,7 @@ use crate::{
33 ArtifactId , Benchmark , BenchmarkData , CollectionId , Commit , CommitType , Date , Profile ,
44} ;
55use crate :: { ArtifactIdNumber , Index , QueryDatum , QueuedCommit } ;
6- use chrono:: { DateTime , TimeZone , Utc } ;
6+ use chrono:: { DateTime , NaiveDateTime , TimeZone , Utc } ;
77use hashbrown:: HashMap ;
88use rusqlite:: params;
99use rusqlite:: OptionalExtension ;
@@ -321,6 +321,7 @@ static MIGRATIONS: &[Migration] = &[
321321 "# ,
322322 ) ,
323323 Migration :: new ( "alter table benchmark add column category text not null default ''" ) ,
324+ Migration :: new ( "alter table pull_request_build add column commit_date timestamp" ) ,
324325] ;
325326
326327#[ async_trait:: async_trait]
@@ -564,21 +565,28 @@ impl Connection for SqliteConnection {
564565 . execute ( params ! [ pr, include, exclude, & runs] )
565566 . unwrap ( ) ;
566567 }
567- async fn pr_attach_commit ( & self , pr : u32 , sha : & str , parent_sha : & str ) -> bool {
568+ async fn pr_attach_commit (
569+ & self ,
570+ pr : u32 ,
571+ sha : & str ,
572+ parent_sha : & str ,
573+ commit_date : Option < DateTime < Utc > > ,
574+ ) -> bool {
575+ let timestamp = commit_date. map ( |d| d. timestamp ( ) ) ;
568576 self . raw_ref ( )
569577 . prepare_cached (
570- "update pull_request_build SET bors_sha = ?, parent_sha = ?
578+ "update pull_request_build SET bors_sha = ?, parent_sha = ?, commit_date = ?
571579 where pr = ? and bors_sha is null" ,
572580 )
573581 . unwrap ( )
574- . execute ( params ! [ sha, parent_sha, pr] )
582+ . execute ( params ! [ sha, parent_sha, timestamp , pr] )
575583 . unwrap ( )
576584 > 0
577585 }
578586 async fn queued_commits ( & self ) -> Vec < QueuedCommit > {
579587 self . raw_ref ( )
580588 . prepare_cached (
581- "select pr, bors_sha, parent_sha, include, exclude, runs from pull_request_build
589+ "select pr, bors_sha, parent_sha, include, exclude, runs, commit_date from pull_request_build
582590 where complete is false and bors_sha is not null
583591 order by requested asc" ,
584592 )
@@ -593,6 +601,7 @@ impl Connection for SqliteConnection {
593601 include : row. get ( 3 ) . unwrap ( ) ,
594602 exclude : row. get ( 4 ) . unwrap ( ) ,
595603 runs : row. get ( 5 ) . unwrap ( ) ,
604+ commit_date : row. get :: < _ , Option < i64 > > ( 6 ) . unwrap ( ) . map ( |timestamp| Date ( DateTime :: from_utc ( NaiveDateTime :: from_timestamp ( timestamp, 0 ) , Utc ) ) )
596605 } )
597606 } )
598607 . collect :: < Result < Vec < _ > , _ > > ( )
@@ -612,7 +621,7 @@ impl Connection for SqliteConnection {
612621 assert_eq ! ( count, 1 , "sha is unique column" ) ;
613622 self . raw_ref ( )
614623 . query_row (
615- "select pr, sha, parent_sha, include, exclude, runs from pull_request_build
624+ "select pr, sha, parent_sha, include, exclude, runs, commit_date from pull_request_build
616625 where sha = ?" ,
617626 params ! [ sha] ,
618627 |row| {
@@ -623,6 +632,7 @@ impl Connection for SqliteConnection {
623632 include : row. get ( 3 ) . unwrap ( ) ,
624633 exclude : row. get ( 4 ) . unwrap ( ) ,
625634 runs : row. get ( 5 ) . unwrap ( ) ,
635+ commit_date : row. get :: < _ , Option < i64 > > ( 6 ) . unwrap ( ) . map ( |timestamp| Date ( DateTime :: from_utc ( NaiveDateTime :: from_timestamp ( timestamp, 0 ) , Utc ) ) )
626636 } )
627637 } ,
628638 )
0 commit comments