Repository: buildbot/buildbot

Issue:
Console_view lines don't change position on expansion
If I expand a changeset in `console_view` the horizontal separation line between changes won't expand as well and then the UI looks weird.


Discussion:
@noc0lour please upload screenshoots when sending UI bugs
I hope that #3108 fixes you issue, but I can't be sure

![20170410103938](https://cloud.githubusercontent.com/assets/4438327/24874601/17a23b66-1dda-11e7-80c1-c5cc05c809fb.png)

I'll try the fixes later :)
dammit, you don't have the same bugs as I see and fixed in #3108.

I can reproduce your bug, though, which is not fixed yet in #3108
also, this also looks weird, we should scale the width with the available screen width.
![20170410124757](https://cloud.githubusercontent.com/assets/4438327/24879499/f8531b4c-1deb-11e7-9aca-85631fab3844.png)



Resolving patch:
diff --git a/master/buildbot/data/buildsets.py b/master/buildbot/data/buildsets.py
--- a/master/buildbot/data/buildsets.py
+++ b/master/buildbot/data/buildsets.py
@@ -60,6 +60,18 @@ def getSs(ssid):
 
         defer.returnValue(buildset)
 
+    fieldMapping = {
+        'buildsetid': 'buildsets.id',
+        'external_idstring': 'buildsets.external_idstring',
+        'reason': 'buildsets.reason',
+        'submitted_at': 'buildsets.submitted_at',
+        'complete': 'buildsets.complete',
+        'complete_at': 'buildsets.complete_at',
+        'results': 'buildsets.results',
+        'parent_buildid': 'buildsets.parent_buildid',
+        'parent_relationship': 'buildsets.parent_relationship'
+    }
+
 
 class BuildsetEndpoint(Db2DataMixin, base.Endpoint):
 
@@ -85,15 +97,11 @@ class BuildsetsEndpoint(Db2DataMixin, base.Endpoint):
 
     def get(self, resultSpec, kwargs):
         complete = resultSpec.popBooleanFilter('complete')
-        d = self.master.db.buildsets.getBuildsets(complete=complete)
+        resultSpec.fieldMapping = self.fieldMapping
+        d = self.master.db.buildsets.getBuildsets(complete=complete, resultSpec=resultSpec)
 
         @d.addCallback
         def db2data(buildsets):
-            # buildset db2data is pretty heavy. for the sake of console_view prefilter the data
-            # should fix it properly in http://trac.buildbot.net/ticket/3537
-            if (resultSpec.order == ['-submitted_at'] and resultSpec.limit and resultSpec.offset is None):
-                buildsets.sort(key=lambda x: x['submitted_at'], reverse=True)
-                buildsets = buildsets[:resultSpec.limit]
             d = defer.DeferredList([self.db2data(bs) for bs in buildsets],
                                    fireOnOneErrback=True, consumeErrors=True)
 
diff --git a/master/buildbot/db/buildsets.py b/master/buildbot/db/buildsets.py
--- a/master/buildbot/db/buildsets.py
+++ b/master/buildbot/db/buildsets.py
@@ -164,7 +164,7 @@ def thd(conn):
             return self._thd_row2dict(conn, row)
         return self.db.pool.do(thd)
 
-    def getBuildsets(self, complete=None):
+    def getBuildsets(self, complete=None, resultSpec=None):
         def thd(conn):
             bs_tbl = self.db.model.buildsets
             q = bs_tbl.select()
@@ -174,6 +174,8 @@ def thd(conn):
                 else:
                     q = q.where((bs_tbl.c.complete == 0) |
                                 (bs_tbl.c.complete == NULL))
+            if resultSpec is not None:
+                return resultSpec.thd_execute(conn, q, lambda x: self._thd_row2dict(conn, x))
             res = conn.execute(q)
             return [self._thd_row2dict(conn, row) for row in res.fetchall()]
         return self.db.pool.do(thd)


Test patch:
diff --git a/master/buildbot/test/fake/fakedb.py b/master/buildbot/test/fake/fakedb.py
--- a/master/buildbot/test/fake/fakedb.py
+++ b/master/buildbot/test/fake/fakedb.py
@@ -1341,7 +1341,7 @@ def getBuildset(self, bsid):
         row = self.buildsets[bsid]
         return defer.succeed(self._row2dict(row))
 
-    def getBuildsets(self, complete=None):
+    def getBuildsets(self, complete=None, resultSpec=None):
         rv = []
         for bs in itervalues(self.buildsets):
             if complete is not None:
@@ -1351,6 +1351,8 @@ def getBuildsets(self, complete=None):
                     rv.append(self._row2dict(bs))
             else:
                 rv.append(self._row2dict(bs))
+        if resultSpec is not None:
+            rv = self.applyResultSpec(rv, resultSpec)
         return defer.succeed(rv)
 
     @defer.inlineCallbacks
diff --git a/master/buildbot/test/unit/test_db_buildsets.py b/master/buildbot/test/unit/test_db_buildsets.py
--- a/master/buildbot/test/unit/test_db_buildsets.py
+++ b/master/buildbot/test/unit/test_db_buildsets.py
@@ -70,7 +70,7 @@ def getBuildset(self, bsid):
 
     def test_signature_getBuildsets(self):
         @self.assertArgSpecMatches(self.db.buildsets.getBuildsets)
-        def getBuildsets(self, complete=None):
+        def getBuildsets(self, complete=None, resultSpec=None):
             pass
 
     def test_signature_getRecentBuildsets(self):