diff options
-rw-r--r-- | lib.php | 20 | ||||
-rw-r--r-- | test_index.php | 12 |
2 files changed, 24 insertions, 8 deletions
@@ -19,6 +19,26 @@ */ /** + * List all packages submitted to the BS. + * + * @param string $upload_dir + * + * @return array +*/ +function get_submitted_packages($upload_dir) +{ + chdir($upload_dir); + + $matches = array(); + $all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.lock' -o -name '*.done' -o -name '*.upload' \) -ctime -$max_modified -printf \"%p\t%T@\\n\""); + $re = "!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.*)(\.src\.rpm(?:\.info)?|\.lock|\.done|\.upload)\s+(\d+\.\d+)$!m"; + $r = preg_match_all($re, + $all_files, + $matches, + PREG_SET_ORDER); +} + +/** * Return a human-readable label for this package build status. * * @param array $pkg package information diff --git a/test_index.php b/test_index.php index 87100b5..40a523b 100644 --- a/test_index.php +++ b/test_index.php @@ -45,15 +45,9 @@ if ($g_user) { $tz = new DateTimeZone('UTC'); $date_gen = date('c'); -chdir($upload_dir); +$matches = get_submitted_packages($upload_dir); -$matches = array(); -$all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.lock' -o -name '*.done' -o -name '*.upload' \) -ctime -$max_modified -printf \"%p\t%T@\\n\""); -$re = "!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.*)(\.src\.rpm(?:\.info)?|\.lock|\.done|\.upload)\s+(\d+\.\d+)$!m"; -$r = preg_match_all($re, - $all_files, - $matches, - PREG_SET_ORDER); +// next block: INPUT: $matches, $_GET['package'] if set $pkgs = array(); $hosts = array(); @@ -142,6 +136,8 @@ ksort($build_dates); $build_count = count($buildtime_total); $buildtime_total = array_sum($buildtime_total); +// above block. OUTPUT: $pkgs, $build_dates, $buildtime_total, $hosts + list($stats, $users, $total, $pkgs) = build_stats($pkgs); $last_pkg = (isset($_GET['last']) && $total > 0) ? reset($pkgs) : null; |