@@ -3,7 +3,7 @@ use crate::{
3
3
ArtifactId , Benchmark , BenchmarkData , CollectionId , Commit , CommitType , Date , Profile ,
4
4
} ;
5
5
use crate :: { ArtifactIdNumber , Index , QueryDatum , QueuedCommit } ;
6
- use chrono:: { DateTime , TimeZone , Utc } ;
6
+ use chrono:: { DateTime , NaiveDateTime , TimeZone , Utc } ;
7
7
use hashbrown:: HashMap ;
8
8
use rusqlite:: params;
9
9
use rusqlite:: OptionalExtension ;
@@ -321,6 +321,7 @@ static MIGRATIONS: &[Migration] = &[
321
321
"# ,
322
322
) ,
323
323
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" ) ,
324
325
] ;
325
326
326
327
#[ async_trait:: async_trait]
@@ -564,21 +565,28 @@ impl Connection for SqliteConnection {
564
565
. execute ( params ! [ pr, include, exclude, & runs] )
565
566
. unwrap ( ) ;
566
567
}
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 ( ) ) ;
568
576
self . raw_ref ( )
569
577
. prepare_cached (
570
- "update pull_request_build SET bors_sha = ?, parent_sha = ?
578
+ "update pull_request_build SET bors_sha = ?, parent_sha = ?, commit_date = ?
571
579
where pr = ? and bors_sha is null" ,
572
580
)
573
581
. unwrap ( )
574
- . execute ( params ! [ sha, parent_sha, pr] )
582
+ . execute ( params ! [ sha, parent_sha, timestamp , pr] )
575
583
. unwrap ( )
576
584
> 0
577
585
}
578
586
async fn queued_commits ( & self ) -> Vec < QueuedCommit > {
579
587
self . raw_ref ( )
580
588
. 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
582
590
where complete is false and bors_sha is not null
583
591
order by requested asc" ,
584
592
)
@@ -593,6 +601,7 @@ impl Connection for SqliteConnection {
593
601
include : row. get ( 3 ) . unwrap ( ) ,
594
602
exclude : row. get ( 4 ) . unwrap ( ) ,
595
603
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 ) ) )
596
605
} )
597
606
} )
598
607
. collect :: < Result < Vec < _ > , _ > > ( )
@@ -612,7 +621,7 @@ impl Connection for SqliteConnection {
612
621
assert_eq ! ( count, 1 , "sha is unique column" ) ;
613
622
self . raw_ref ( )
614
623
. 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
616
625
where sha = ?" ,
617
626
params ! [ sha] ,
618
627
|row| {
@@ -623,6 +632,7 @@ impl Connection for SqliteConnection {
623
632
include : row. get ( 3 ) . unwrap ( ) ,
624
633
exclude : row. get ( 4 ) . unwrap ( ) ,
625
634
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 ) ) )
626
636
} )
627
637
} ,
628
638
)
0 commit comments