1. Fix duplicate entries showing up in the table.
2. Modify the code to make only one sql query and then process the info than mak
e one sql query per xy in a table.
3. Add reporting clii.
4. Also move the common libraries used by the cli and web interface into query_l
ib.py.

From: Radha Ramachandran <radha@google.com>
Signed-off-by: Martin Bligh <mbligh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@908 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/frontend.py b/tko/frontend.py
index 22e6be9..df1fa49 100755
--- a/tko/frontend.py
+++ b/tko/frontend.py
@@ -55,7 +55,18 @@
 		 the table."""
 		rows, field_name_in_main_table = select(db, field, value=None, distinct=True)
 		groupnames = sorted([row for row in rows])
-		return [klass(db, field_name_in_main_table, groupname) for groupname in groupnames]
+
+		# collapse duplicates where records have the same name but
+		# multiple index values
+		headers = {}
+		for field_name, idx_value in groupnames:
+			if headers.has_key(field_name):
+				headers[field_name].append(idx_value)
+			else:
+				headers[field_name] = [idx_value]
+		headers = headers.items()
+		headers.sort()
+		return [klass(db, field_name_in_main_table, groupname) for groupname in headers]
 
 
 	def __init__(self, db, idx_name, name):
@@ -213,6 +224,7 @@
 		if not rows:
 			return None
 		(self.tag, self.machine_idx) = rows[0]
+		self.job_idx = job_idx
 
  
 class iteration: