[Fusionforge-commits] FusionForge branch master updated. 1b67cf0da9500a162b809336f63499ccb8fb6818

Sylvain Beucler beuc-inria at fusionforge.org
Fri Jan 16 15:48:10 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  1b67cf0da9500a162b809336f63499ccb8fb6818 (commit)
       via  ca61b1b1e5d49c912050a6e87bc09de854831012 (commit)
      from  4cb89004303b95c25af25f5eef19f2d7c13da238 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1b67cf0da9500a162b809336f63499ccb8fb6818
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Fri Jan 16 15:47:30 2015 +0100

    reactivity: user-friendly view of the system tasks queue

diff --git a/src/www/my/systasks.php b/src/www/my/systasks.php
index 3670e4e..02f0b11 100644
--- a/src/www/my/systasks.php
+++ b/src/www/my/systasks.php
@@ -42,23 +42,63 @@ if ($_SERVER['QUERY_STRING'] == 'create') {
 }
 
 
-site_user_header(array('title' => _('System actions queue')));
+site_user_header(array('title' => _('System actions queue (past day)')));
 
 $u = session_get_user();
 $groups = $u->getGroups();
 $gids = array();
 foreach($groups as $g)
-		$gids[] = $g->getID();
+	$gids[] = $g->getID();
 $gids = implode(',', $gids);
 
-$res = pg_query_params("SELECT * FROM systasks WHERE user_id=$1 or group_id IN ($gids)"
-					   . " AND requested > NOW() - interval '1 day'",
-					   array($u->getID()));
-while($row = db_fetch_array($res)) {
-		print_r($row);
-		print "<br />";
+$title_arr = array(
+	_('Task ID'),
+	_('Plugin'),
+	_('SysTask Type ID'),
+	_('Group ID'),
+	_('Status'),
+	_('Requested'),
+	_('Started'),
+	_('Ended'),
+);
+
+echo $HTML->listTableTop ($title_arr);
+$query = "
+SELECT systask_id, unix_group_name,
+plugin_name, systasks.status,
+    EXTRACT(epoch FROM requested) AS requested,
+    EXTRACT(epoch FROM started) AS started,
+    EXTRACT(epoch FROM stopped) AS stopped,
+    EXTRACT(epoch FROM started-requested) AS queued,
+    EXTRACT(epoch FROM stopped-started) AS run
+  FROM systasks LEFT JOIN groups ON (systasks.group_id = groups.group_id)
+    LEFT JOIN plugins ON (systasks.plugin_id = plugins.plugin_id)
+  WHERE user_id=$1 or systasks.group_id IN ($gids)
+  AND requested > NOW() - interval '1 day'
+  ORDER BY systask_id";
+$res = pg_query_params($query, array($u->getID()));
+for ($i=0; $i<db_numrows($res); $i++) {
+	$cells = array();
+	$cells[][] = db_result($res,$i,'systask_id');
+	$plugin_name = db_result($res,$i,'plugin_name');
+	if ($plugin_name == null)
+		$cells[][] = 'core';
+	else
+		$cells[][] = $plugin_name;
+	$cells[][] = db_result($res,$i,'systask_type_id');
+	$cells[][] = db_result($res,$i,'unix_group_name');
+	$cells[][] = db_result($res,$i,'status');
+	$cells[][] = date("H:i:s", db_result($res, $i,'requested'));
+	$cells[][] = date("H:i:s", db_result($res, $i,'started'))
+		. ' (+' . round(db_result($res, $i,'queued'), 1) . 's)';
+	$cells[][] = date("H:i:s", db_result($res, $i,'stopped'))
+		. ' (+' . round(db_result($res, $i,'run'), 1) . 's)';
+	echo $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($i+1, true)), $cells);
 }
 
+
+echo $HTML->listTableBottom();
+
 site_user_footer();
 
 // Local Variables:

commit ca61b1b1e5d49c912050a6e87bc09de854831012
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Fri Jan 16 15:46:28 2015 +0100

    reactivity: save jobs start/stop time

diff --git a/src/bin/systasksd b/src/bin/systasksd
index 1dcdb39..b264ec1 100755
--- a/src/bin/systasksd
+++ b/src/bin/systasksd
@@ -124,7 +124,7 @@ while (true) {
 								  $arr['systask_id']));
 			continue;
 		}
-		db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+		db_query_params("UPDATE systasks SET status=$1, started=now() WHERE systask_id=$2",
 						array('WIP', $arr['systask_id']));
 		cron_acquire_lock($script);
 		$ret = null;
@@ -132,11 +132,11 @@ while (true) {
 		system("$script\n", $ret);
 		if ($ret == 0) {
 			if ($verbose) print "DONE\n";
-			db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+			db_query_params("UPDATE systasks SET status=$1, stopped=now() WHERE systask_id=$2",
 							array('DONE', $arr['systask_id']));
 		} else {
 			if ($verbose) print "ERROR\n";
-			db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+			db_query_params("UPDATE systasks SET status=$1, stopped=now() WHERE systask_id=$2",
 							array('ERROR', $arr['systask_id']));
 		}
 	}

-----------------------------------------------------------------------

Summary of changes:
 src/bin/systasksd       |    6 ++---
 src/www/my/systasks.php |   56 ++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list