11use 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+ } ;
35use crate :: { ArtifactIdNumber , Index , QueryDatum , QueuedCommit } ;
46use chrono:: { DateTime , TimeZone , Utc } ;
57use hashbrown:: HashMap ;
68use rusqlite:: params;
79use rusqlite:: OptionalExtension ;
810use std:: convert:: TryFrom ;
911use std:: path:: PathBuf ;
12+ use std:: str:: FromStr ;
1013use std:: sync:: Mutex ;
1114use std:: sync:: Once ;
1215use std:: time:: Duration ;
@@ -402,7 +405,9 @@ impl Connection for SqliteConnection {
402405 async fn load_index ( & mut self ) -> Index {
403406 let commits = self
404407 . 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+ )
406411 . unwrap ( )
407412 . query_map ( params ! [ ] , |row| {
408413 Ok ( (
@@ -416,6 +421,7 @@ impl Connection for SqliteConnection {
416421 None => Date ( Utc . ymd ( 2001 , 01 , 01 ) . and_hms ( 0 , 0 , 0 ) ) ,
417422 }
418423 } ,
424+ r#type : CommitType :: from_str ( & row. get :: < _ , String > ( 3 ) ?) . unwrap ( ) ,
419425 } ,
420426 ) )
421427 } )
@@ -696,11 +702,7 @@ impl Connection for SqliteConnection {
696702 let ( name, date, ty) = match artifact {
697703 crate :: ArtifactId :: Commit ( commit) => (
698704 commit. sha . to_string ( ) ,
699- if commit. is_try ( ) {
700- None
701- } else {
702- Some ( commit. date . 0 )
703- } ,
705+ Some ( commit. date . 0 ) ,
704706 if commit. is_try ( ) { "try" } else { "master" } ,
705707 ) ,
706708 crate :: ArtifactId :: Tag ( a) => ( a. clone ( ) , None , "release" ) ,
@@ -894,6 +896,7 @@ impl Connection for SqliteConnection {
894896 . map ( |d| Utc . timestamp ( d, 0 ) )
895897 . map ( Date )
896898 . unwrap_or_else ( || Date :: ymd_hms ( 2001 , 01 , 01 , 0 , 0 , 0 ) ) ,
899+ r#type : CommitType :: from_str ( & ty) . unwrap ( ) ,
897900 } ) ,
898901 "release" => ArtifactId :: Tag ( name) ,
899902 _ => {
@@ -1091,10 +1094,14 @@ impl Connection for SqliteConnection {
10911094 "master" => Some ( ArtifactId :: Commit ( Commit {
10921095 sha : artifact. to_owned ( ) ,
10931096 date : Date ( Utc . timestamp ( date. expect ( "master has date" ) , 0 ) ) ,
1097+ r#type : CommitType :: Master ,
10941098 } ) ) ,
10951099 "try" => Some ( ArtifactId :: Commit ( Commit {
10961100 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 ,
10981105 } ) ) ,
10991106 "release" => Some ( ArtifactId :: Tag ( artifact. to_owned ( ) ) ) ,
11001107 _ => panic ! ( "unknown artifact type: {:?}" , ty) ,
0 commit comments