summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-sysadm/2011-January/002347.html
diff options
context:
space:
mode:
Diffstat (limited to 'zarb-ml/mageia-sysadm/2011-January/002347.html')
-rw-r--r--zarb-ml/mageia-sysadm/2011-January/002347.html331
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(&quot;rejected&quot;, $pkg[&quot;status&quot;]))
++ return &quot;rejected&quot;;
++ if (array_key_exists(&quot;youri&quot;, $pkg[&quot;status&quot;])) {
++ if (array_key_exists(&quot;src&quot;, $pkg[&quot;status&quot;]))
++ return &quot;youri&quot;;
++ else
++ return &quot;uploaded&quot;;
++ }
++ if (array_key_exists(&quot;failure&quot;, $pkg[&quot;status&quot;]))
++ return &quot;failure&quot;;
++ if (array_key_exists(&quot;done&quot;, $pkg[&quot;status&quot;]))
++ return &quot;partial&quot;;
++ if (array_key_exists(&quot;build&quot;, $pkg[&quot;status&quot;]))
++ return &quot;building&quot;;
++ if (array_key_exists(&quot;todo&quot;, $pkg[&quot;status&quot;]))
++ return &quot;todo&quot;;
++ return &quot;unknown&quot;;
++}
++
++/**
++ * @param integer $num
++ *
++ * @return string
++*/
++function plural($num) {
++ if ($num &gt; 1)
++ return &quot;s&quot;;
++}
++
++/**
++ * Return timestamp from package key
++ * @param string $key package submission key
++ *
++ * @return integer
++*/
++
++function key2timestamp($key) {
++ global $tz;
++
++ $date = DateTime::createFromFormat(&quot;YmdHis&quot;, $key+0, $tz);
++ if ($date &lt;= 0)
++ return null;
++
++ return $date-&gt;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&lt;60)
++ return $diff . &quot; second&quot; . plural($diff);
++ $diff = round($diff/60);
++ if ($diff&lt;60)
++ return $diff . &quot; minute&quot; . plural($diff);
++ $diff = round($diff/60);
++ if ($diff&lt;24)
++ return $diff . &quot; hour&quot; . plural($diff);
++ $diff = round($diff/24);
++
++ return $diff . &quot; day&quot; . 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(&quot;rejected&quot;, $pkg[&quot;status&quot;]))
+- return &quot;rejected&quot;;
+- if (array_key_exists(&quot;youri&quot;, $pkg[&quot;status&quot;])) {
+- if (array_key_exists(&quot;src&quot;, $pkg[&quot;status&quot;]))
+- return &quot;youri&quot;;
+- else
+- return &quot;uploaded&quot;;
+- }
+- if (array_key_exists(&quot;failure&quot;, $pkg[&quot;status&quot;]))
+- return &quot;failure&quot;;
+- if (array_key_exists(&quot;done&quot;, $pkg[&quot;status&quot;]))
+- return &quot;partial&quot;;
+- if (array_key_exists(&quot;build&quot;, $pkg[&quot;status&quot;]))
+- return &quot;building&quot;;
+- if (array_key_exists(&quot;todo&quot;, $pkg[&quot;status&quot;]))
+- return &quot;todo&quot;;
+- return &quot;unknown&quot;;
+-}
++// count all packages statuses
++$stats = array(
++ 'uploaded' =&gt; 0,
++ 'failure' =&gt; 0,
++ 'todo' =&gt; 0,
++ 'building' =&gt; 0,
++ 'partial' =&gt; 0,
++ 'built' =&gt; 0,
++);
++$total = count($pkgs);
+
+-/**
+- * @param integer $num
+- *
+- * @return string
+-*/
+-function plural($num) {
+- if ($num &gt; 1)
+- return &quot;s&quot;;
+-}
++// count users' packages
++$users = array();
+
+-/**
+- * Return timestamp from package key
+- * @param string $key package submission key
+- *
+- * @return integer
+-*/
++if ($total &gt; 0) {
++ foreach ($pkgs as $key =&gt; $p) {
++ $pkgs[$key]['type'] = pkg_gettype($p);
+
+-function key2timestamp($key) {
+- global $tz;
++ $stats[$pkgs[$key]['type']] += 1;
+
+- $date = DateTime::createFromFormat(&quot;YmdHis&quot;, $key+0, $tz);
+- if ($date &lt;= 0)
+- return null;
+-
+- return $date-&gt;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&lt;60)
+- return $diff . &quot; second&quot; . plural($diff);
+- $diff = round($diff/60);
+- if ($diff&lt;60)
+- return $diff . &quot; minute&quot; . plural($diff);
+- $diff = round($diff/60);
+- if ($diff&lt;24)
+- return $diff . &quot; hour&quot; . plural($diff);
+- $diff = round($diff/24);
++// feedback labels
++$badges = array(
++ 'uploaded' =&gt; 'Congrats %s! \o/',
++ 'failure' =&gt; 'Booooo! /o\\',
++ 'todo' =&gt; '',
++ 'building' =&gt; '',
++ 'partial' =&gt; '',
++ 'built' =&gt; ''
++);
+
+- return $diff . &quot; day&quot; . plural($diff);
++foreach ($stats as $k =&gt; $v) {
++ Header(&quot;X-BS-Queue-$k: $v&quot;);
+ }
+
++$w = $stats['todo'] - 10;
++if($w &lt; 0)
++ $w = 0;
++$w = $w * 60;
++Header(&quot;X-BS-Throttle: $w&quot;);
+ ?&gt;
+ &lt;!DOCTYPE html&gt;
+ &lt;html lang=&quot;en&quot;&gt;
+@@ -251,41 +297,8 @@
+ &lt;td class=&quot;status-box&quot;&gt;&lt;/td&gt;
+ T;
+
+-// count all packages statuses
+-$stats = array(
+- 'uploaded' =&gt; 0,
+- 'failure' =&gt; 0,
+- 'todo' =&gt; 0,
+- 'building' =&gt; 0,
+- 'partial' =&gt; 0,
+- 'built' =&gt; 0,
+-);
+-$total = count($pkgs);
+-
+-// count users' packages
+-$users = array();
+-
+-// feedback labels
+-$badges = array(
+- 'uploaded' =&gt; 'Congrats %s! \o/',
+- 'failure' =&gt; 'Booooo! /o\\',
+- 'todo' =&gt; '',
+- 'building' =&gt; '',
+- 'partial' =&gt; '',
+- 'built' =&gt; ''
+-);
+-
+ if ($total &gt; 0) {
+ foreach ($pkgs as $key =&gt; $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: &lt;/pipermail/mageia-sysadm/attachments/20110121/d701158a/attachment-0001.html&gt;
+</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>