,
],
'host_git' => [
- 'sql' => preg_replace('/[\t\r\n]+/',' ',"
+ 'sql_' => preg_replace('/[\t\r\n]+/',' ',"
+ SELECT host,max(CAST(val as INTEGER)) FROM host_info WHERE key LIKE 'git.%exit_code' GROUP BY host
+ "),
+ 'sql_' => preg_replace('/[\t\r\n]+/',' ',"
SELECT host
,max(updated) as last_updated
,min(updated) as first_updated
,(SELECT count(path.val) FROM host_info path WHERE path.host=hi.host AND path.key LIKE 'git.%.path') as repos
- ,max(val) as exit
+ ,max(val) as exit
FROM host_info hi
WHERE key LIKE 'git.%exit_code'
GROUP BY host ORDER BY last_updated DESC, host
"),
+ 'sql' => preg_replace('/[\t\r\n]/','',"
+ SELECT host
+ ,max(updated) as last_updated
+ ,min(updated) as first_updated
+ ,(SELECT count(path.val) FROM host_info path WHERE path.host=hi.host AND path.key LIKE 'git.%.path') as repos
+ ,(SELECT max(CAST(ex.val as INTEGER)) as exit FROM host_info ex
+ WHERE ex.host=hi.host AND ex.key LIKE 'git.%.exit_code'
+ ) as exit
+ FROM host_info hi
+ WHERE key LIKE 'git.%'
+ GROUP BY host ORDER BY last_updated DESC, host
+"),
'row_parse_pre' => function(&$row,$t) {
+ # NB 13.10.24 if ($row['exit'] === null) debug(
+ # NB 13.10.24 $t->db()->row("SELECT max(cast(val as integer)) FROM host_info"
+ # NB 13.10.24 ." WHERE host=".$t->db()->quote($row['host'])
+ # NB 13.10.24 ." AND key like ".$t->db()->quote('%exit_code')
+ # NB 13.10.24 )
+ # NB 13.10.24 );
+ # NB 13.10.24 if ($row['exit'] === null) $row['exit'] =
+ # NB 13.10.24 $t->db()->row("SELECT max(cast(val as integer)) FROM host_info"
+ # NB 13.10.24 ." WHERE host=".$t->db()->quote($row['host'])
+ # NB 13.10.24 ." AND key like ".$t->db()->quote('%exit_code')
+ # NB 13.10.24 )
+ # NB 13.10.24 ;
+ # NB 13.10.24 $row['exit'] =
+ # NB 13.10.24 $t->db()->row("SELECT max(val) FROM host_info"
+ # NB 13.10.24 ." WHERE host=".$t->db()->quote($row['host'])
+ # NB 13.10.24 ." AND key like ".$t->db()->quote('git.%exit_code')
+ # NB 13.10.24 )
+ # NB 13.10.24 ;
+
foreach ($row as $k=>$v) {
if (strpos($k,'updated') !== false) {
$row[$k] = preg_replace('/\..*$/','',$v);