Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: third_party/buildbot_8_4p1/buildbot/db/buildsets.py

Issue 302283005: Backported getRecentBuildsets from buildbot 0.8.8 (to use it in RietveldPollerWithCache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # This file is part of Buildbot. Buildbot is free software: you can 1 # This file is part of Buildbot. Buildbot is free software: you can
2 # redistribute it and/or modify it under the terms of the GNU General Public 2 # redistribute it and/or modify it under the terms of the GNU General Public
3 # License as published by the Free Software Foundation, version 2. 3 # License as published by the Free Software Foundation, version 2.
4 # 4 #
5 # This program is distributed in the hope that it will be useful, but WITHOUT 5 # This program is distributed in the hope that it will be useful, but WITHOUT
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8 # details. 8 # details.
9 # 9 #
10 # You should have received a copy of the GNU General Public License along with 10 # You should have received a copy of the GNU General Public License along with
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if complete is not None: 183 if complete is not None:
184 if complete: 184 if complete:
185 q = q.where(bs_tbl.c.complete != 0) 185 q = q.where(bs_tbl.c.complete != 0)
186 else: 186 else:
187 q = q.where((bs_tbl.c.complete == 0) | 187 q = q.where((bs_tbl.c.complete == 0) |
188 (bs_tbl.c.complete == None)) 188 (bs_tbl.c.complete == None))
189 res = conn.execute(q) 189 res = conn.execute(q)
190 return [ self._row2dict(row) for row in res.fetchall() ] 190 return [ self._row2dict(row) for row in res.fetchall() ]
191 return self.db.pool.do(thd) 191 return self.db.pool.do(thd)
192 192
193 def getRecentBuildsets(self, count, branch=None, repository=None,
194 complete=None):
195 def thd(conn):
196 bs_tbl = self.db.model.buildsets
197 ch_tbl = self.db.model.changes
198 j = sa.join(self.db.model.buildsets,
199 self.db.model.sourcestamps)
200 j = j.join(self.db.model.sourcestamp_changes)
201 j = j.join(ch_tbl)
202 q = sa.select(columns=[bs_tbl], from_obj=[j],
203 distinct=True)
204 q = q.order_by(sa.desc(bs_tbl.c.id))
205 q = q.limit(count)
206
207 if complete is not None:
208 if complete:
209 q = q.where(bs_tbl.c.complete != 0)
210 else:
211 q = q.where((bs_tbl.c.complete == 0) |
212 (bs_tbl.c.complete == None))
213 if branch:
214 q = q.where(ch_tbl.c.branch == branch)
215 if repository:
216 q = q.where(ch_tbl.c.repository == repository)
217 res = conn.execute(q)
218 return list(reversed([self._row2dict(row)
219 for row in res.fetchall()]))
220 return self.db.pool.do(thd)
221
193 def getBuildsetProperties(self, buildsetid): 222 def getBuildsetProperties(self, buildsetid):
194 """ 223 """
195 Return the properties for a buildset, in the same format they were 224 Return the properties for a buildset, in the same format they were
196 given to L{addBuildset}. 225 given to L{addBuildset}.
197 226
198 Note that this method does not distinguish a nonexistent buildset from 227 Note that this method does not distinguish a nonexistent buildset from
199 a buildset with no properties, and returns C{{}} in either case. 228 a buildset with no properties, and returns C{{}} in either case.
200 229
201 @param buildsetid: buildset ID 230 @param buildsetid: buildset ID
202 231
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 def _row2dict(self, row): 315 def _row2dict(self, row):
287 def mkdt(epoch): 316 def mkdt(epoch):
288 if epoch: 317 if epoch:
289 return epoch2datetime(epoch) 318 return epoch2datetime(epoch)
290 return BsDict(external_idstring=row.external_idstring, 319 return BsDict(external_idstring=row.external_idstring,
291 reason=row.reason, sourcestampid=row.sourcestampid, 320 reason=row.reason, sourcestampid=row.sourcestampid,
292 submitted_at=mkdt(row.submitted_at), 321 submitted_at=mkdt(row.submitted_at),
293 complete=bool(row.complete), 322 complete=bool(row.complete),
294 complete_at=mkdt(row.complete_at), results=row.results, 323 complete_at=mkdt(row.complete_at), results=row.results,
295 bsid=row.id) 324 bsid=row.id)
OLDNEW
« no previous file with comments | « third_party/buildbot_8_4p1/README.chromium ('k') | third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698