recent checkins page speed improvements with hidng feature
authorkrishnatejaperannagari <krishnatejaperannagari@gmail.com>
Tue, 17 Jun 2014 06:07:54 +0000 (11:37 +0530)
committerkrishnatejaperannagari <krishnatejaperannagari@gmail.com>
Tue, 24 Jun 2014 16:02:04 +0000 (21:32 +0530)
Signed-off-by: krishnatejaperannagari <krishnatejaperannagari@gmail.com>
buildfarm/web/__init__.py

index 08d577a1ba3402c676d8a2dda53aedf2efc4cf2a..600ce751920cc5e12c90716d3e31c07384ee787e 100755 (executable)
@@ -887,14 +887,25 @@ class DiffPage(HistoryPage):
 
 class RecentCheckinsPage(HistoryPage):
 
-    limit = 40
+    limit = 10
 
-    def render(self, myself, tree, author=None):
+    def render(self, myself, tree, gitcount=None, navigation=None, author=None):
         t = self.buildfarm.trees[tree]
         interesting = list()
         authors = {"ALL": "ALL"}
         branch = t.get_branch()
         re_author = re.compile("^(.*) <(.*)>$")
+                
+        if navigation == "Previous":
+            gitstart = int(gitcount) - ( 2 * self.limit )
+            gitstop = int(gitcount) - self.limit
+        elif navigation == "Next":
+            gitstart = int(gitcount)
+            gitstop = int(gitcount) + self.limit
+        else:
+            gitstart = 0
+            gitstop = self.limit   
+
         for entry in branch.log(limit=HISTORY_HORIZON):
             m = re_author.match(entry.author)
             authors[m.group(2)] = m.group(1)
@@ -910,11 +921,26 @@ class RecentCheckinsPage(HistoryPage):
         yield "<input type='hidden' name='tree' value='%s'/>" % tree
         yield "<input type='hidden' name='function', value='Recent Checkins'/>"
         yield "</form>"
-
-        for entry in interesting[: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 "<input type='submit' name='navigation' value='Previous' style='position:absolute;left:0px;'/>"
+        if len(interesting) > gitstop:
+            yield "<input type='submit' name='navigation' value='Next' style='position:absolute;right:0px;'/>"
+        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):
@@ -1021,8 +1047,10 @@ class BuildFarmApp(object):
             elif fn_name == "Recent_Checkins":
                 # validate the tree
                 author = get_param(form, 'author')
+                gitcount = get_param(form, 'gitcount')
+                navigation = get_param(form, 'navigation')
                 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, gitcount, navigation, author)))
             elif fn_name == "diff":
                 revision = get_param(form, 'revision')
                 page = DiffPage(self.buildfarm)