src/Pure/Admin/build_log.scala
changeset 65783 d3d5cb2d6866
parent 65781 6cd11999f3a3
child 65804 73ed0ebac3b0
equal deleted inserted replaced
65782:4935bac8a850 65783:d3d5cb2d6866
   656     val ml_timing_gc = SQL.Column.long("ml_timing_gc")
   656     val ml_timing_gc = SQL.Column.long("ml_timing_gc")
   657     val ml_timing_factor = SQL.Column.double("ml_timing_factor")
   657     val ml_timing_factor = SQL.Column.double("ml_timing_factor")
   658     val heap_size = SQL.Column.long("heap_size")
   658     val heap_size = SQL.Column.long("heap_size")
   659     val status = SQL.Column.string("status")
   659     val status = SQL.Column.string("status")
   660     val ml_statistics = SQL.Column.bytes("ml_statistics")
   660     val ml_statistics = SQL.Column.bytes("ml_statistics")
       
   661     val known = SQL.Column.bool("known")
   661 
   662 
   662     val meta_info_table =
   663     val meta_info_table =
   663       build_log_table("meta_info", log_name :: Prop.all_props ::: Settings.all_settings)
   664       build_log_table("meta_info", log_name :: Prop.all_props ::: Settings.all_settings)
   664 
   665 
   665     val sessions_table =
   666     val sessions_table =
   687     }
   688     }
   688 
   689 
   689     def recent_time(days: Int): SQL.Source =
   690     def recent_time(days: Int): SQL.Source =
   690       "now() - INTERVAL '" + days.max(0) + " days'"
   691       "now() - INTERVAL '" + days.max(0) + " days'"
   691 
   692 
   692     def recent_pull_date_table(days: Int): SQL.Table =
   693     def recent_pull_date_table(days: Int, rev: String = ""): SQL.Table =
   693     {
   694     {
   694       val table = pull_date_table
   695       val table = pull_date_table
   695       SQL.Table("recent_pull_date", table.columns,
   696       SQL.Table("recent_pull_date", table.columns,
   696         table.select(table.columns, "WHERE " + pull_date(table) + " > " + recent_time(days)))
   697         table.select(table.columns,
       
   698           "WHERE " + pull_date(table) + " > " + recent_time(days) +
       
   699           (if (rev == "") "" else " OR " + Prop.isabelle_version(table) + " = " + SQL.string(rev))))
   697     }
   700     }
   698 
   701 
   699     def select_recent_log_names(days: Int): SQL.Source =
   702     def select_recent_log_names(days: Int): SQL.Source =
   700     {
   703     {
   701       val table1 = meta_info_table
   704       val table1 = meta_info_table
   702       val table2 = recent_pull_date_table(days)
   705       val table2 = recent_pull_date_table(days)
   703       table1.select(List(log_name), distinct = true) + SQL.join_inner + table2.query_named +
   706       table1.select(List(log_name), distinct = true) + SQL.join_inner + table2.query_named +
   704         " ON " + Prop.isabelle_version(table1) + " = " + Prop.isabelle_version(table2)
   707         " ON " + Prop.isabelle_version(table1) + " = " + Prop.isabelle_version(table2)
       
   708     }
       
   709 
       
   710     def select_recent_isabelle_versions(days: Int, rev: String = "", sql: SQL.Source = "")
       
   711       : SQL.Source =
       
   712     {
       
   713       val table1 = recent_pull_date_table(days, rev = rev)
       
   714       val table2 = meta_info_table
       
   715       val aux_table = SQL.Table("aux", table2.columns, table2.select(sql = sql))
       
   716 
       
   717       val columns =
       
   718         List(Prop.isabelle_version(table1), pull_date(table1),
       
   719           known.copy(expr = log_name(aux_table) + " IS NOT NULL"))
       
   720       SQL.select(columns, distinct = true) +
       
   721         table1.query_named + SQL.join_outer + aux_table.query_named +
       
   722         " ON " + Prop.isabelle_version(table1) + " = " + Prop.isabelle_version(aux_table) +
       
   723         " ORDER BY " + pull_date(table1) + " DESC"
   705     }
   724     }
   706 
   725 
   707 
   726 
   708     /* universal view on main data */
   727     /* universal view on main data */
   709 
   728