]> git.samba.org - build-farm.git/blobdiff - buildfarm/web/__init__.py
Add constant for maximum build age.
[build-farm.git] / buildfarm / web / __init__.py
index 438d41218ed062f58345050d2c1ec58405d56055..7cd1a7ed968dba90ea4b9ec8e80b0f2a10f5dd99 100755 (executable)
@@ -58,6 +58,11 @@ webdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "we
 GITWEB_BASE = "https://gitweb.samba.org"
 HISTORY_HORIZON = 1000
 
+# Maximum age of builds to consider when displaying summary page statistics.
+# Note that trees only get rebuilt when they change, so this value is
+# intentionally set to a high value to cope with trees that don't change often.
+SUMMARY_MAX_BUILD_AGE = (180 * 24 * 60 * 60)
+
 # this is automatically filled in
 deadhosts = []
 
@@ -727,16 +732,15 @@ class ViewSummaryPage(BuildFarmPage):
         # output when we want
         broken_table = ""
 
-        builds = self.buildfarm.get_last_builds()
+        builds = self.buildfarm.get_summary_builds(min_age=time.time() - SUMMARY_MAX_BUILD_AGE)
 
-        for build in builds:
-            host_count[build.tree]+=1
-            status = build.status()
+        for tree, status in builds:
+            host_count[tree]+=1
 
             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):
@@ -886,14 +890,15 @@ class DiffPage(HistoryPage):
 
 class RecentCheckinsPage(HistoryPage):
 
-    limit = 40
+    limit = 10
 
-    def render(self, myself, tree, author=None):
+    def render(self, myself, tree, gitstart, author=None):
         t = self.buildfarm.trees[tree]
         interesting = list()
         authors = {"ALL": "ALL"}
         branch = t.get_branch()
         re_author = re.compile("^(.*) <(.*)>$")
         for entry in branch.log(limit=HISTORY_HORIZON):
             m = re_author.match(entry.author)
             authors[m.group(2)] = m.group(1)
@@ -910,11 +915,28 @@ class RecentCheckinsPage(HistoryPage):
         yield "<input type='hidden' name='function', value='Recent Checkins'/>"
         yield "</form>"
 
-        for entry in interesting[:self.limit]:
+        gitstop = gitstart + self.limit
+
+        for entry in interesting[gitstart:gitstop]:
             changes = branch.changes_summary(entry.revision)
             yield "".join(self.history_row_html(myself, entry, t, changes))
         yield "\n"
 
+        yield "<form method='GET'>"
+        yield "<div class='newform'>\n"
+        if gitstart != 0:
+            yield "<button name='gitstart' type='submit' value=" + str(gitstart - self.limit) + " style='position:absolute;left:0px;'>Previous</button>"
+        if len(interesting) > gitstop:
+            yield "<button name='gitstart' type='submit' value=" + str(gitstop) + " style='position:absolute;right:0px;'>Next</button>"
+        yield "<input type='hidden' name='function', value='Recent Checkins'/>"
+        yield "<input type='hidden' name='gitcount' value='%s'/>" % gitstop
+        if author and author != "ALL":
+            yield "<input type='hidden' name='author' value='%s'/>" % author
+        yield "<input type='hidden' name='tree' value='%s'/>" % tree
+        yield "</div>\n"
+        yield "</form>"
+        yield "<br>"
+
 
 class BuildFarmApp(object):
 
@@ -1020,8 +1042,13 @@ class BuildFarmApp(object):
             elif fn_name == "Recent_Checkins":
                 # validate the tree
                 author = get_param(form, 'author')
+                gitstart = get_param(form, 'gitstart')
+                if gitstart is None:
+                    gitstart = 0
+                else:
+                    gitstart = int(gitstart)
                 page = RecentCheckinsPage(self.buildfarm)
-                yield "".join(self.html_page(form, page.render(myself, tree, author)))
+                yield "".join(self.html_page(form, page.render(myself, tree, gitstart, author)))
             elif fn_name == "diff":
                 revision = get_param(form, 'revision')
                 page = DiffPage(self.buildfarm)