]> git.nbdom.net Git - nb.git/commitdiff
etc/dbq/data.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 13 Oct 2024 20:19:36 +0000 (22:19 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 13 Oct 2024 20:19:36 +0000 (22:19 +0200)
etc/dbq/data.php

index f468d4c0a4342b77cfc99018cd88dea1dd84b95d..542fb4f702b8b90a899588ea723b142ddb72913a 100644 (file)
@@ -8,17 +8,51 @@ $DBQ['data'] = [
                                        ,
                        ],
                        '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);