Merge branch 'query4summarypage' of git://github.com/krishnatejaperannagari/build...
authorJelmer Vernooij <jelmer@samba.org>
Sat, 2 Aug 2014 18:03:58 +0000 (20:03 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 2 Aug 2014 18:03:58 +0000 (20:03 +0200)
buildfarm/__init__.py
buildfarm/build.py
buildfarm/web/__init__.py

index 7c4428e80bd4aa374ce425f68f8a9b3c0d42a615..ec0556ab19538f2f2b1305aa432b8f6345076532 100644 (file)
@@ -143,6 +143,19 @@ class BuildFarm(object):
         result = self._get_store().find(StormBuild)
         return distinct_builds(result.order_by(Desc(StormBuild.upload_time)))
 
+    def get_summary_builds(self):
+        """returns tree and status to the ViewSummaryPage class"""
+        store = self._get_store()
+        return store.execute("""
+SELECT obd.tree, obd.status AS status_str 
+FROM build obd
+INNER JOIN(
+       SELECT MAX(age) age, tree, host, compiler
+       FROM build
+       GROUP BY tree, host, compiler
+) ibd ON obd.age = ibd.age AND obd.tree = ibd.tree AND  obd.host = ibd.host AND obd.compiler = ibd.compiler;
+""")
+
     def get_tree_builds(self, tree):
         result = self._get_store().find(StormBuild,
             Cast(StormBuild.tree, "TEXT") == Cast(tree, "TEXT"))
index fae37a179709b038109c2118833b7169f8569fdf..a064bfaf6984eeb600087bc889e371547dc3a231 100644 (file)
@@ -566,8 +566,9 @@ class BuildResultStore(object):
         os.link(build.basename+".log", new_basename+".log")
         if os.path.exists(build.basename+".err"):
             os.link(build.basename+".err", new_basename+".err")
-        new_build = StormBuild(new_basename, build.tree, build.host,
-            build.compiler, rev)
+        # They are supposed to be in unicode only but since comparision for sumary page depends on them 
+        # the unicode conversion is done to avoid duplicates when running query in summary_builds
+        new_build = StormBuild(new_basename, unicode(build.tree), unicode(build.host), unicode(build.compiler), rev)
         new_build.checksum = build.log_checksum()
         new_build.upload_time = build.upload_time
         new_build.status_str = build.status().__serialize__()
index b1f0fb4096c3ba9411ae0a08f837bc639fb3ed60..92730a0b4e3f198a1b014ef7f622690b781bce14 100755 (executable)
@@ -43,6 +43,7 @@ from buildfarm.build import (
     LogFileMissing,
     NoSuchBuildError,
     NoTestOutput,
+    BuildStatus,
     )
 
 import cgi
@@ -727,16 +728,16 @@ class ViewSummaryPage(BuildFarmPage):
         # output when we want
         broken_table = ""
 
-        builds = self.buildfarm.get_last_builds()
+        builds = self.buildfarm.get_summary_builds()
 
-        for build in builds:
-            host_count[build.tree]+=1
-            status = build.status()
+        for tree, status_str in builds:
+            host_count[tree]+=1
+            status = BuildStatus.__deserialize__(status_str)
 
             if status.failed:
-                broken_count[build.tree]+=1
+                broken_count[tree]+=1
                 if "panic" in status.other_failures:
-                    panic_count[build.tree]+=1
+                    panic_count[tree]+=1
         return (host_count, broken_count, panic_count)
 
     def render_text(self, myself):