diff options
Diffstat (limited to 'zarb-ml/mageia-sysadm/2011-January/002347.html')
-rw-r--r-- | zarb-ml/mageia-sysadm/2011-January/002347.html | 331 |
1 files changed, 331 insertions, 0 deletions
diff --git a/zarb-ml/mageia-sysadm/2011-January/002347.html b/zarb-ml/mageia-sysadm/2011-January/002347.html new file mode 100644 index 000000000..428adc6e9 --- /dev/null +++ b/zarb-ml/mageia-sysadm/2011-January/002347.html @@ -0,0 +1,331 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> + <HEAD> + <TITLE> [Mageia-sysadm] [333] Add queue current status and suggested time until next submit in the HTTP header + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B333%5D%20Add%20queue%20current%20status%20and%20suggested%20time%0A%20until%20next%20submit%20in%20the%20HTTP%20header&In-Reply-To=%3C20110121114103.97CA942C61%40valstar.mageia.org%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="002346.html"> + <LINK REL="Next" HREF="002348.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[Mageia-sysadm] [333] Add queue current status and suggested time until next submit in the HTTP header</H1> + <B>root at mageia.org</B> + <A HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B333%5D%20Add%20queue%20current%20status%20and%20suggested%20time%0A%20until%20next%20submit%20in%20the%20HTTP%20header&In-Reply-To=%3C20110121114103.97CA942C61%40valstar.mageia.org%3E" + TITLE="[Mageia-sysadm] [333] Add queue current status and suggested time until next submit in the HTTP header">root at mageia.org + </A><BR> + <I>Fri Jan 21 12:41:03 CET 2011</I> + <P><UL> + <LI>Previous message: <A HREF="002346.html">[Mageia-sysadm] Puppet Report for rabbit.mageia.org +</A></li> + <LI>Next message: <A HREF="002348.html">[Mageia-sysadm] Puppet Report for jonund.mageia.org +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#2347">[ date ]</a> + <a href="thread.html#2347">[ thread ]</a> + <a href="subject.html#2347">[ subject ]</a> + <a href="author.html#2347">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>Revision: 333 +Author: pterjan +Date: 2011-01-21 12:41:03 +0100 (Fri, 21 Jan 2011) +Log Message: +----------- +Add queue current status and suggested time until next submit in the HTTP header + +Modified Paths: +-------------- + build_system/web/index.php + +Modified: build_system/web/index.php +=================================================================== +--- build_system/web/index.php 2011-01-20 17:35:27 UTC (rev 332) ++++ build_system/web/index.php 2011-01-21 11:41:03 UTC (rev 333) +@@ -24,6 +24,84 @@ + + error_reporting(E_ALL); + ++/** ++ * @param array $pkg ++ * ++ * @return string ++*/ ++function pkg_gettype($pkg) { ++ if (array_key_exists("rejected", $pkg["status"])) ++ return "rejected"; ++ if (array_key_exists("youri", $pkg["status"])) { ++ if (array_key_exists("src", $pkg["status"])) ++ return "youri"; ++ else ++ return "uploaded"; ++ } ++ if (array_key_exists("failure", $pkg["status"])) ++ return "failure"; ++ if (array_key_exists("done", $pkg["status"])) ++ return "partial"; ++ if (array_key_exists("build", $pkg["status"])) ++ return "building"; ++ if (array_key_exists("todo", $pkg["status"])) ++ return "todo"; ++ return "unknown"; ++} ++ ++/** ++ * @param integer $num ++ * ++ * @return string ++*/ ++function plural($num) { ++ if ($num > 1) ++ return "s"; ++} ++ ++/** ++ * Return timestamp from package key ++ * @param string $key package submission key ++ * ++ * @return integer ++*/ ++ ++function key2timestamp($key) { ++ global $tz; ++ ++ $date = DateTime::createFromFormat("YmdHis", $key+0, $tz); ++ if ($date <= 0) ++ return null; ++ ++ return $date->getTimestamp(); ++} ++ ++function timediff($start, $end) { ++/** ++ * Return human-readable time difference ++ * ++ * @param integer $start timestamp ++ * @param integer $end timestamp, defaults to now ++ * ++ * @return string ++*/ ++ if (is_null($end)) { ++ $end = time(); ++ } ++ $diff = $end - $start; ++ if ($diff<60) ++ return $diff . " second" . plural($diff); ++ $diff = round($diff/60); ++ if ($diff<60) ++ return $diff . " minute" . plural($diff); ++ $diff = round($diff/60); ++ if ($diff<24) ++ return $diff . " hour" . plural($diff); ++ $diff = round($diff/24); ++ ++ return $diff . " day" . plural($diff); ++} ++ + $g_user = isset($_GET['user']) ? htmlentities(strip_tags($_GET['user'])) : null; + + $upload_dir = '/home/schedbot/uploads'; +@@ -97,84 +175,52 @@ + // sort by key in reverse order to have more recent pkgs first + krsort($pkgs); + +-/** +- * @param array $pkg +- * +- * @return string +-*/ +-function pkg_gettype($pkg) { +- if (array_key_exists("rejected", $pkg["status"])) +- return "rejected"; +- if (array_key_exists("youri", $pkg["status"])) { +- if (array_key_exists("src", $pkg["status"])) +- return "youri"; +- else +- return "uploaded"; +- } +- if (array_key_exists("failure", $pkg["status"])) +- return "failure"; +- if (array_key_exists("done", $pkg["status"])) +- return "partial"; +- if (array_key_exists("build", $pkg["status"])) +- return "building"; +- if (array_key_exists("todo", $pkg["status"])) +- return "todo"; +- return "unknown"; +-} ++// count all packages statuses ++$stats = array( ++ 'uploaded' => 0, ++ 'failure' => 0, ++ 'todo' => 0, ++ 'building' => 0, ++ 'partial' => 0, ++ 'built' => 0, ++); ++$total = count($pkgs); + +-/** +- * @param integer $num +- * +- * @return string +-*/ +-function plural($num) { +- if ($num > 1) +- return "s"; +-} ++// count users' packages ++$users = array(); + +-/** +- * Return timestamp from package key +- * @param string $key package submission key +- * +- * @return integer +-*/ ++if ($total > 0) { ++ foreach ($pkgs as $key => $p) { ++ $pkgs[$key]['type'] = pkg_gettype($p); + +-function key2timestamp($key) { +- global $tz; ++ $stats[$pkgs[$key]['type']] += 1; + +- $date = DateTime::createFromFormat("YmdHis", $key+0, $tz); +- if ($date <= 0) +- return null; +- +- return $date->getTimestamp(); ++ if (!array_key_exists($p['user'], $users)) ++ $users[$p['user']] = 1; ++ else ++ $users[$p['user']] += 1; ++ } + } + +-function timediff($start, $end) { +-/** +- * Return human-readable time difference +- * +- * @param integer $start timestamp +- * @param integer $end timestamp, defaults to now +- * +- * @return string +-*/ +- if (is_null($end)) { +- $end = time(); +- } +- $diff = $end - $start; +- if ($diff<60) +- return $diff . " second" . plural($diff); +- $diff = round($diff/60); +- if ($diff<60) +- return $diff . " minute" . plural($diff); +- $diff = round($diff/60); +- if ($diff<24) +- return $diff . " hour" . plural($diff); +- $diff = round($diff/24); ++// feedback labels ++$badges = array( ++ 'uploaded' => 'Congrats %s! \o/', ++ 'failure' => 'Booooo! /o\\', ++ 'todo' => '', ++ 'building' => '', ++ 'partial' => '', ++ 'built' => '' ++); + +- return $diff . " day" . plural($diff); ++foreach ($stats as $k => $v) { ++ Header("X-BS-Queue-$k: $v"); + } + ++$w = $stats['todo'] - 10; ++if($w < 0) ++ $w = 0; ++$w = $w * 60; ++Header("X-BS-Throttle: $w"); + ?> + <!DOCTYPE html> + <html lang="en"> +@@ -251,41 +297,8 @@ + <td class="status-box"></td> + T; + +-// count all packages statuses +-$stats = array( +- 'uploaded' => 0, +- 'failure' => 0, +- 'todo' => 0, +- 'building' => 0, +- 'partial' => 0, +- 'built' => 0, +-); +-$total = count($pkgs); +- +-// count users' packages +-$users = array(); +- +-// feedback labels +-$badges = array( +- 'uploaded' => 'Congrats %s! \o/', +- 'failure' => 'Booooo! /o\\', +- 'todo' => '', +- 'building' => '', +- 'partial' => '', +- 'built' => '' +-); +- + if ($total > 0) { + foreach ($pkgs as $key => $p) { +- $p['type'] = pkg_gettype($p); +- +- $stats[$p['type']] += 1; +- +- if (!array_key_exists($p['user'], $users)) +- $users[$p['user']] = 1; +- else +- $users[$p['user']] += 1; +- + $s .= sprintf($tmpl, + $p['type'], + timediff(key2timestamp($key)) . ' ago', +-------------- next part -------------- +An HTML attachment was scrubbed... +URL: </pipermail/mageia-sysadm/attachments/20110121/d701158a/attachment-0001.html> +</PRE> + + + + + + + + + + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="002346.html">[Mageia-sysadm] Puppet Report for rabbit.mageia.org +</A></li> + <LI>Next message: <A HREF="002348.html">[Mageia-sysadm] Puppet Report for jonund.mageia.org +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#2347">[ date ]</a> + <a href="thread.html#2347">[ thread ]</a> + <a href="subject.html#2347">[ subject ]</a> + <a href="author.html#2347">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://www.mageia.org/mailman/listinfo/mageia-sysadm">More information about the Mageia-sysadm +mailing list</a><br> +</body></html> |