1
1
use crate :: pool:: { Connection , ConnectionManager , ManagedConnection , Transaction } ;
2
- use crate :: { ArtifactId , Benchmark , BenchmarkData , CollectionId , Commit , Date , Profile } ;
2
+ use crate :: {
3
+ ArtifactId , Benchmark , BenchmarkData , CollectionId , Commit , CommitType , Date , Profile ,
4
+ } ;
3
5
use crate :: { ArtifactIdNumber , Index , QueryDatum , QueuedCommit } ;
4
6
use chrono:: { DateTime , TimeZone , Utc } ;
5
7
use hashbrown:: HashMap ;
6
8
use rusqlite:: params;
7
9
use rusqlite:: OptionalExtension ;
8
10
use std:: convert:: TryFrom ;
9
11
use std:: path:: PathBuf ;
12
+ use std:: str:: FromStr ;
10
13
use std:: sync:: Mutex ;
11
14
use std:: sync:: Once ;
12
15
use std:: time:: Duration ;
@@ -402,7 +405,9 @@ impl Connection for SqliteConnection {
402
405
async fn load_index ( & mut self ) -> Index {
403
406
let commits = self
404
407
. raw ( )
405
- . prepare ( "select id, name, date from artifact where type = 'master' or type = 'try'" )
408
+ . prepare (
409
+ "select id, name, date, type from artifact where type = 'master' or type = 'try'" ,
410
+ )
406
411
. unwrap ( )
407
412
. query_map ( params ! [ ] , |row| {
408
413
Ok ( (
@@ -416,6 +421,7 @@ impl Connection for SqliteConnection {
416
421
None => Date ( Utc . ymd ( 2001 , 01 , 01 ) . and_hms ( 0 , 0 , 0 ) ) ,
417
422
}
418
423
} ,
424
+ r#type : CommitType :: from_str ( & row. get :: < _ , String > ( 3 ) ?) . unwrap ( ) ,
419
425
} ,
420
426
) )
421
427
} )
@@ -696,11 +702,7 @@ impl Connection for SqliteConnection {
696
702
let ( name, date, ty) = match artifact {
697
703
crate :: ArtifactId :: Commit ( commit) => (
698
704
commit. sha . to_string ( ) ,
699
- if commit. is_try ( ) {
700
- None
701
- } else {
702
- Some ( commit. date . 0 )
703
- } ,
705
+ Some ( commit. date . 0 ) ,
704
706
if commit. is_try ( ) { "try" } else { "master" } ,
705
707
) ,
706
708
crate :: ArtifactId :: Tag ( a) => ( a. clone ( ) , None , "release" ) ,
@@ -894,6 +896,7 @@ impl Connection for SqliteConnection {
894
896
. map ( |d| Utc . timestamp ( d, 0 ) )
895
897
. map ( Date )
896
898
. unwrap_or_else ( || Date :: ymd_hms ( 2001 , 01 , 01 , 0 , 0 , 0 ) ) ,
899
+ r#type : CommitType :: from_str ( & ty) . unwrap ( ) ,
897
900
} ) ,
898
901
"release" => ArtifactId :: Tag ( name) ,
899
902
_ => {
@@ -1091,10 +1094,14 @@ impl Connection for SqliteConnection {
1091
1094
"master" => Some ( ArtifactId :: Commit ( Commit {
1092
1095
sha : artifact. to_owned ( ) ,
1093
1096
date : Date ( Utc . timestamp ( date. expect ( "master has date" ) , 0 ) ) ,
1097
+ r#type : CommitType :: Master ,
1094
1098
} ) ) ,
1095
1099
"try" => Some ( ArtifactId :: Commit ( Commit {
1096
1100
sha : artifact. to_owned ( ) ,
1097
- date : Date :: ymd_hms ( 2000 , 1 , 1 , 0 , 0 , 0 ) ,
1101
+ date : date
1102
+ . map ( |d| Date ( Utc . timestamp ( d, 0 ) ) )
1103
+ . unwrap_or_else ( || Date :: ymd_hms ( 2000 , 1 , 1 , 0 , 0 , 0 ) ) ,
1104
+ r#type : CommitType :: Try ,
1098
1105
} ) ) ,
1099
1106
"release" => Some ( ArtifactId :: Tag ( artifact. to_owned ( ) ) ) ,
1100
1107
_ => panic ! ( "unknown artifact type: {:?}" , ty) ,
0 commit comments