88
88
defer.returnValue(cxt)
90
def getSourceStampKey(self, ss):
90
def getSourceStampKey(self, sourcestamps):
91
91
"""Given two source stamps, we want to assign them to the same row if
92
92
they are the same version of code, even if they differ in minor detail.
94
94
This function returns an appropriate comparison key for that.
96
return (ss.branch, ss.revision, ss.patch)
96
# TODO: Maybe order sourcestamps in key by codebases names?
97
return tuple([(ss.branch, ss.revision, ss.patch) for ss in sourcestamps])
99
def clearRecentBuildsCache(self):
100
self.__recentBuildsCache__ = {}
98
102
def getRecentBuilds(self, builder, numBuilds, branch):
103
cache = getattr(self, '__recentBuildsCache__', {})
104
key = (builder.getName(), branch, numBuilds)
108
# cache miss, get the value and store it in the cache
109
result = [b for b in self.__getRecentBuilds(builder, numBuilds, branch)]
113
def __getRecentBuilds(self, builder, numBuilds, branch):
100
115
get a list of most recent builds on given builder
135
150
if categories and builder.category not in categories:
137
152
for build in self.getRecentBuilds(builder, numBuilds, branch):
138
#TODO: support multiple sourcestamps
139
ss = build.getSourceStamps(absolute=True)[0]
140
key= self.getSourceStampKey(ss)
141
start = build.getTimes()[0]
153
ss = build.getSourceStamps(absolute=True)
154
key = self.getSourceStampKey(ss)
155
start = min(build.getTimes())
142
156
if key not in sourcestamps or sourcestamps[key][1] > start:
143
157
sourcestamps[key] = (ss, start)
145
159
# now sort those and take the NUMBUILDS most recent
146
sourcestamps = sourcestamps.values()
147
sourcestamps.sort(lambda x, y: cmp(x[1], y[1]))
148
sourcestamps = map(lambda tup : tup[0], sourcestamps)
149
sourcestamps = sourcestamps[-numBuilds:]
160
sourcestamps = sorted(sourcestamps.itervalues(), key = lambda stamp: stamp[1])
161
sourcestamps = [stamp[0] for stamp in sourcestamps][-numBuilds:]
151
163
return sourcestamps
176
188
cxt.update({'categories': categories,
177
189
'branch': branch,
178
190
'ANYBRANCH': ANYBRANCH,
179
'stamps': map(SourceStamp.asDict, stamps)
191
'stamps': [map(SourceStamp.asDict, sstamp) for sstamp in stamps],
182
sortedBuilderNames = status.getBuilderNames()[:]
183
sortedBuilderNames.sort()
194
sortedBuilderNames = sorted(status.getBuilderNames())
185
196
cxt['builders'] = []
194
205
for build in self.getRecentBuilds(builder, numBuilds, branch):
195
#TODO: support multiple sourcestamps
196
if len(build.getSourceStamps()) == 1:
197
ss = build.getSourceStamps(absolute=True)[0]
198
key= self.getSourceStampKey(ss)
199
for i in range(len(stamps)):
200
if key == self.getSourceStampKey(stamps[i]) and builds[i] is None:
206
ss = build.getSourceStamps(absolute=True)
207
key = self.getSourceStampKey(ss)
209
for i, sstamp in enumerate(stamps):
210
if key == self.getSourceStampKey(sstamp) and builds[i] is None:
203
213
b = yield self.builder_cxt(request, builder)
243
254
cxt.update({'categories': categories,
244
255
'branch': branch,
245
256
'ANYBRANCH': ANYBRANCH,
246
'stamps': map(SourceStamp.asDict, stamps),
257
'stamps': [map(SourceStamp.asDict, sstamp) for sstamp in stamps],
249
sortedBuilderNames = status.getBuilderNames()[:]
250
sortedBuilderNames.sort()
260
sortedBuilderNames = sorted(status.getBuilderNames())
252
262
cxt['sorted_builder_names'] = sortedBuilderNames
253
263
cxt['builder_builds'] = builder_builds = []
266
276
for build in self.getRecentBuilds(builder, numBuilds, branch):
267
277
#TODO: support multiple sourcestamps
268
if len(build.getSourceStamps()) == 1:
269
ss = build.getSourceStamps(absolute=True)[0]
270
key = self.getSourceStampKey(ss)
271
for i in range(len(stamps)):
272
if key == self.getSourceStampKey(stamps[i]) and builds[i] is None:
278
ss = build.getSourceStamps(absolute=True)
279
key = self.getSourceStampKey(ss)
281
for i, sstamp in enumerate(stamps):
282
if key == self.getSourceStampKey(sstamp) and builds[i] is None:
275
285
b = yield self.builder_cxt(request, builder)
276
286
builders.append(b)
278
288
builder_builds.append(map(lambda b: self.build_cxt(request, b), builds))
290
self.clearRecentBuildsCache()
280
291
template = request.site.buildbot_service.templates.get_template('grid_transposed.html')
281
defer.returnValue(template.render(**cxt))
b'\\ No newline at end of file'
292
defer.returnValue(template.render(**cxt))