Skip to content

Commit

Permalink
Limit the display to 24h when a branch or committer filter is specified
Browse files Browse the repository at this point in the history
for the waterfall (and not other limit is explicitly given).

TEST=test_status.EventGenerator
  • Loading branch information
jeisinger authored and Dustin J. Mitchell committed Feb 20, 2010
1 parent fb6e733 commit 8293230
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
4 changes: 2 additions & 2 deletions buildbot/changes/manager.py
Expand Up @@ -115,9 +115,9 @@ def addChange(self, change):

# IEventSource methods

def eventGenerator(self, branches=[], categories=[], committers=[]):
def eventGenerator(self, branches=[], categories=[], committers=[], minTime=0):
return self.parent.db.changeEventGenerator(branches, categories,
committers)
committers, minTime)

def getChangeNumberedNow(self, changeid, t=None):
return self.parent.db.getChangeNumberedNow(changeid, t)
Expand Down
4 changes: 3 additions & 1 deletion buildbot/db.py
Expand Up @@ -684,7 +684,7 @@ def _txn_addChangeToDatabase(self, t, change):
(change.number, propname, encoded_value))
self.notify("add-change", change.number)

def changeEventGenerator(self, branches=[], categories=[], committers=[]):
def changeEventGenerator(self, branches=[], categories=[], committers=[], minTime=0):
q = "SELECT changeid FROM changes"
args = []
if branches or categories or committers:
Expand All @@ -699,6 +699,8 @@ def changeEventGenerator(self, branches=[], categories=[], committers=[]):
if committers:
pieces.append("author IN %s" % self.parmlist(len(committers)))
args.extend(list(committers))
if minTime:
pieces.append("when_timestamp > %d" % minTime)
q += " AND ".join(pieces)
q += " ORDER BY changeid DESC"
rows = self.runQueryNow(q, tuple(args))
Expand Down
5 changes: 4 additions & 1 deletion buildbot/interfaces.py
Expand Up @@ -444,7 +444,7 @@ def unsubscribe(receiver):
delivered."""

class IEventSource(Interface):
def eventGenerator(branches=[], categories=[], committers=[]):
def eventGenerator(branches=[], categories=[], committers=[], minTime=0):
"""This function creates a generator which will yield all of this
object's status events, starting with the most recent and progressing
backwards in time. These events provide the IStatusEvent interface.
Expand All @@ -464,6 +464,9 @@ def eventGenerator(branches=[], categories=[], committers=[]):
@param comitters: a list of committers. The generator should only
return events caused by one of the listed committers. If the list is
empty or None, events from every committers should be returned.
@param minTime: a timestamp. Do not generate events occuring prior to
this timestamp.
"""

class IBuildStatus(Interface):
Expand Down
6 changes: 5 additions & 1 deletion buildbot/status/builder.py
Expand Up @@ -1841,7 +1841,7 @@ def generateFinishedBuilds(self, branches=[],
if got >= num_builds:
return

def eventGenerator(self, branches=[], categories=[], committers=[]):
def eventGenerator(self, branches=[], categories=[], committers=[], minTime=0):
"""This function creates a generator which will provide all of this
Builder's status events, starting with the most recent and
progressing backwards in time. """
Expand All @@ -1866,6 +1866,8 @@ def eventGenerator(self, branches=[], categories=[], committers=[]):
if Nb == 1:
continue
break
if b.getTimes()[0] < minTime:
break
if branches and not b.getSourceStamp().branch in branches:
continue
if categories and not b.getBuilder().getCategory() in categories:
Expand All @@ -1886,6 +1888,8 @@ def eventGenerator(self, branches=[], categories=[], committers=[]):
yield e
eventIndex -= 1
e = self.getEvent(eventIndex)
if e and e.getTimes()[0] < minTime:
break

def subscribe(self, receiver):
# will get builderChangedState, buildStarted, and buildFinished
Expand Down
7 changes: 5 additions & 2 deletions buildbot/status/web/waterfall.py
Expand Up @@ -449,8 +449,10 @@ def buildGrid(self, request, builders):
minTime = maxTime - int(request.args["show_time"][0])
elif "first_time" in request.args:
minTime = int(request.args["first_time"][0])
elif filterBranches or filterCommitters:
minTime = util.now() - 24 * 60 * 60
else:
minTime = None
minTime = 0
spanLength = 10 # ten-second chunks
req_events=int(request.args.get("num_events", [self.num_events])[0])
if self.num_events_max and req_events > self.num_events_max:
Expand Down Expand Up @@ -494,7 +496,8 @@ def get_event_from(g):
for s in sources:
gen = insertGaps(s.eventGenerator(filterBranches,
filterCategories,
filterCommitters),
filterCommitters,
minTime),
showEvents,
lastEventTime)
sourceGenerators.append(gen)
Expand Down
25 changes: 19 additions & 6 deletions buildbot/test/runs/test_status.py
Expand Up @@ -114,17 +114,26 @@ def getProjectName(self):

class MyBuilder(builder.BuilderStatus):
nextBuildNumber = 0
def newBuild(self):
number = self.nextBuildNumber
self.nextBuildNumber += 1
s = MyBuild(self, number, None, False)
s.waitUntilFinished().addCallback(self._buildFinished)
return s

class MyBuild(builder.BuildStatus):
testlogs = []
def __init__(self, parent, number, results):
def __init__(self, parent, number, results, finished=True):
builder.BuildStatus.__init__(self, parent, number)
self.results = results
self.source = SourceStamp(revision="1.14")
self.reason = "build triggered by changes"
self.finished = True
self.finished = finished
def getLogs(self):
return self.testlogs
def buildStarted(self, build, started):
self.started = started
self.builder.buildStarted(self)

class MyLookup:
implements(interfaces.IEmailLookup)
Expand Down Expand Up @@ -1888,15 +1897,15 @@ def test_rmbuilds(self):
])

class EventGenerator(unittest.TestCase):
def makeGenerator(selfx, reasons=[]):
def makeGenerator(self, reasons=[], minTime=0):
b = MyBuilder("bname")
b1 = b.newBuild()
b1.setSourceStamp(SourceStamp(changes=[Change("foo", [], "")]))
b1.buildStarted(b1)
b1.buildStarted(b1, 1)
b2 = b.newBuild()
b2.setSourceStamp(SourceStamp(changes=[Change("bar", [], "")]))
b2.buildStarted(b2)
return b.eventGenerator([], [], reasons)
b2.buildStarted(b2, 2)
return b.eventGenerator([], [], reasons, minTime)

def testEventGenerator_Unfiltered(self):
gen = self.makeGenerator()
Expand All @@ -1905,3 +1914,7 @@ def testEventGenerator_Unfiltered(self):
def testEventGenerator_Filtered(self):
gen = self.makeGenerator(["foo"])
self.failUnlessEqual(len([e for e in gen]), 1)

def testEventGenerator_MinTime(self):
gen = self.makeGenerator([], 2)
self.failUnlessEqual(len([e for e in gen]), 1)

0 comments on commit 8293230

Please sign in to comment.