From 2e4dff035075a377aaca17307f2e7190b16a6e73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Sat, 19 Sep 2009 11:58:58 +0000
Subject: [PATCH]  - use loop to avoid duplication  - add information about
 priority

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29116 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFActivity/bin/watch_activities | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/product/CMFActivity/bin/watch_activities b/product/CMFActivity/bin/watch_activities
index 38415a0672..2714b23a64 100755
--- a/product/CMFActivity/bin/watch_activities
+++ b/product/CMFActivity/bin/watch_activities
@@ -29,13 +29,12 @@ if [ "$INTERVAL" == "" ] ; then
   INTERVAL=5
 fi
 
-SELECT="""
-SELECT count(path) AS message, method_id, processing, processing_node FROM message GROUP BY method_id, processing, processing_node;
-SELECT count(path) AS message_queue, method_id, processing, processing_node FROM message_queue GROUP BY method_id, processing, processing_node;
-SELECT count(path) AS message, processing, processing_node FROM message GROUP BY processing, processing_node;
-SELECT count(path) AS message_queue, processing, processing_node FROM message_queue GROUP BY processing, processing_node;
-SELECT count(path) AS message_count FROM message;
-SELECT count(path) AS message_queue_count FROM message_queue;
-"""
-
+SELECT=""
+for t in message message_queue ; do
+  SELECT=$SELECT"""
+  SELECT count(path) AS $t, method_id, processing, processing_node AS node, min(priority) AS min_pri, max(priority) AS max_pri FROM $t GROUP BY method_id, processing, processing_node;
+  SELECT count(path) AS $t, processing, processing_node, min(priority) AS min_pri, max(priority) AS max_pri FROM $t GROUP BY processing, processing_node;
+  SELECT count(path) AS ${t}_count FROM $t;
+  """
+done
 watch -n $INTERVAL "mysql $MYSQL_OPT --disable-pager -t -e '$SELECT' "
-- 
2.30.9