src/Pure/Admin/build_log.scala
changeset 66855 c9d413fca1ec
parent 66046 37226f74f33a
child 66856 6b90c688a6dc
equal deleted inserted replaced
66854:e23d73f43fb6 66855:c9d413fca1ec
   682 
   682 
   683     val ml_statistics_table =
   683     val ml_statistics_table =
   684       build_log_table("ml_statistics", List(log_name, session_name, ml_statistics))
   684       build_log_table("ml_statistics", List(log_name, session_name, ml_statistics))
   685 
   685 
   686 
   686 
       
   687     /* AFP versions */
       
   688 
       
   689     val isabelle_afp_versions_table: SQL.Table =
       
   690     {
       
   691       val version1 = Prop.isabelle_version
       
   692       val version2 = Prop.afp_version
       
   693       build_log_table("isabelle_afp_versions", List(version1.copy(primary_key = true), version2),
       
   694         SQL.select(List(version1, version2), distinct = true) + meta_info_table +
       
   695         " WHERE " + version1 + " IS NOT NULL AND " + version2 + " IS NOT NULL")
       
   696     }
       
   697 
       
   698 
   687     /* earliest pull date for repository version (PostgreSQL queries) */
   699     /* earliest pull date for repository version (PostgreSQL queries) */
   688 
   700 
   689     val pull_date = SQL.Column.date("pull_date")
   701     val pull_date = SQL.Column.date("pull_date")
   690 
   702 
   691     val pull_date_table: SQL.Table =
   703     val pull_date_table: SQL.Table =
   695         "SELECT " + version + ", min(" + Prop.build_start + ") AS " + pull_date +
   707         "SELECT " + version + ", min(" + Prop.build_start + ") AS " + pull_date +
   696         " FROM " + meta_info_table +
   708         " FROM " + meta_info_table +
   697         " WHERE " + version + " IS NOT NULL AND " + Prop.build_start + " IS NOT NULL" +
   709         " WHERE " + version + " IS NOT NULL AND " + Prop.build_start + " IS NOT NULL" +
   698         " GROUP BY " + version)
   710         " GROUP BY " + version)
   699     }
   711     }
       
   712 
       
   713     val afp_pull_date_table: SQL.Table =
       
   714     {
       
   715       val version1 = Prop.isabelle_version
       
   716       val version2 = Prop.afp_version
       
   717       val table1 = pull_date_table
       
   718       val table2 = isabelle_afp_versions_table
       
   719       build_log_table("afp_pull_date", List(version1.copy(primary_key = true), version2, pull_date),
       
   720         table1.select(List(version1(table1), version2(table2), pull_date(table1))) +
       
   721         SQL.join_inner + table2.query_named + " ON " + version1(table1) + " = " + version1(table2))
       
   722     }
       
   723 
       
   724 
       
   725     /* recent entries */
   700 
   726 
   701     def recent_time(days: Int): SQL.Source =
   727     def recent_time(days: Int): SQL.Source =
   702       "now() - INTERVAL '" + days.max(0) + " days'"
   728       "now() - INTERVAL '" + days.max(0) + " days'"
   703 
   729 
   704     def recent_pull_date_table(days: Int, rev: String = ""): SQL.Table =
   730     def recent_pull_date_table(days: Int, rev: String = ""): SQL.Table =
   797     def update_database(db: PostgreSQL.Database, dirs: List[Path], ml_statistics: Boolean = false)
   823     def update_database(db: PostgreSQL.Database, dirs: List[Path], ml_statistics: Boolean = false)
   798     {
   824     {
   799       write_info(db, Log_File.find_files(dirs), ml_statistics = ml_statistics)
   825       write_info(db, Log_File.find_files(dirs), ml_statistics = ml_statistics)
   800 
   826 
   801       db.create_view(Data.pull_date_table)
   827       db.create_view(Data.pull_date_table)
       
   828       db.create_view(Data.afp_pull_date_table)
   802       db.create_view(Data.universal_table)
   829       db.create_view(Data.universal_table)
   803     }
   830     }
   804 
   831 
   805     def snapshot_database(db: PostgreSQL.Database, sqlite_database: Path,
   832     def snapshot_database(db: PostgreSQL.Database, sqlite_database: Path,
   806       days: Int = 100, ml_statistics: Boolean = false)
   833       days: Int = 100, ml_statistics: Boolean = false)