From d9fc9efa15bf4145c16664345984cd23aab42a0d Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 16 Oct 2024 10:48:57 +0200 Subject: [PATCH] etc/dbq/data.php --- etc/dbq/data.php | 12 +++++++++++- lib/php/nb.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/etc/dbq/data.php b/etc/dbq/data.php index 078ddb11..83d589ce 100644 --- a/etc/dbq/data.php +++ b/etc/dbq/data.php @@ -58,15 +58,25 @@ $DBQ['data'] = [ 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 + ,0 as count ,(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 + ,(SELECT string_agg((name.val),' ') as repos FROM host_info name WHERE name.host=hi.host AND name.key LIKE 'git.%.name') as repos FROM host_info hi WHERE key LIKE 'git.%' GROUP BY host ORDER BY last_updated DESC, host "), 'row_parse_pre' => function(&$row,$t) { + + #$repos = array_map(function($a){return basename($a);},explode(' ',$row['repos'])); + if (isset($row['repos'])) { + $repos = explode(' ',$row['repos']); + sort($repos); + $row['repos'] = join(' ',$repos); + $row['count'] = count($repos); + } + foreach ($row as $k=>$v) { if (strpos($k,'updated') !== false) { $row[$k] = preg_replace('/\..*$/','',$v); diff --git a/lib/php/nb.php b/lib/php/nb.php index 5d28310c..be8e77b1 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -191,7 +191,7 @@ class Nb { * Does what it says */ public static function ar_map($return,$array,$as_hash=false) { - # NB 15.12.22: Depreciated use direct php arra_map functions + # NB 15.12.22: Depreciated use direct php array_map functions $map = $array; # NB 30.11.22: Does not work get error message mb_strlen does not exists #bye($return); -- 2.47.3