@@ -231,8 +231,18 @@ def gettimelinedata(request):
231231
232232 timeline_list = {'error' : 'None' , 'timelines' : []}
233233
234- executables = data .get ('exe' , "" ).split ("," )
235- if not filter (None , executables ):
234+ executable_ids = data .get ('exe' , '' ).split (',' )
235+
236+ executables = []
237+ for i in executable_ids :
238+ if not i :
239+ continue
240+ try :
241+ executables .append (Executable .objects .get (id = int (i )))
242+ except Executable .DoesNotExist :
243+ pass
244+
245+ if not executables :
236246 timeline_list ['error' ] = "No executables selected"
237247 return HttpResponse (json .dumps (timeline_list ))
238248 environment = None
@@ -270,22 +280,19 @@ def gettimelinedata(request):
270280 'branches' : {},
271281 'baseline' : "None" ,
272282 }
273- # Temporary
274- trunks = []
283+ append = False
275284 for proj in Project .objects .filter (track = True ):
276285 try :
277- default_branch = Branch .objects .get (
286+ branch = Branch .objects .get (
278287 project = proj , name = proj .default_branch )
279288 except Branch .DoesNotExist :
280289 continue
281- else :
282- trunks .append (default_branch )
283- # For now, we'll only work with trunk branches
284- append = False
285- for branch in trunks :
286- append = False
287- timeline ['branches' ][branch .name ] = {}
290+
291+ # For now, we'll only work with trunk branches
288292 for executable in executables :
293+ if executable .project != proj :
294+ continue
295+
289296 resultquery = Result .objects .filter (
290297 benchmark = bench
291298 ).filter (
@@ -299,6 +306,7 @@ def gettimelinedata(request):
299306 ).order_by ('-revision__date' )[:number_of_revs ]
300307 if not len (resultquery ):
301308 continue
309+ timeline ['branches' ].setdefault (branch .name , {})
302310
303311 results = []
304312 for res in resultquery :
@@ -333,32 +341,34 @@ def gettimelinedata(request):
333341 res .revision .get_short_commitid (), res .revision .tag , branch .name
334342 ]
335343 )
336- timeline ['branches' ][branch .name ][executable ] = results
344+ timeline ['branches' ][branch .name ][executable . id ] = results
337345 append = True
338346
339- if baselinerev is not None and append :
340- try :
341- baselinevalue = Result .objects .get (
342- executable = baselineexe ,
343- benchmark = bench ,
344- revision = baselinerev ,
345- environment = environment
346- ).value
347- except Result .DoesNotExist :
348- timeline ['baseline' ] = "None"
349- else :
350- # determine start and end revision (x axis)
351- # from longest data series
352- results = []
353- for exe in timeline ['branches' ][branch .name ]:
354- if len (timeline ['branches' ][branch .name ][exe ]) > len (results ):
355- results = timeline ['branches' ][branch .name ][exe ]
356- end = results [0 ][0 ]
357- start = results [len (results ) - 1 ][0 ]
358- timeline ['baseline' ] = [
359- [str (start ), baselinevalue ],
360- [str (end ), baselinevalue ]
361- ]
347+ if baselinerev is not None and append :
348+ try :
349+ baselinevalue = Result .objects .get (
350+ executable = baselineexe ,
351+ benchmark = bench ,
352+ revision = baselinerev ,
353+ environment = environment
354+ ).value
355+ except Result .DoesNotExist :
356+ timeline ['baseline' ] = "None"
357+ else :
358+ # determine start and end revision (x axis)
359+ # from longest data series
360+ results = []
361+ for branch in timeline ['branches' ]:
362+ for exe in timeline ['branches' ][branch ]:
363+ if len (timeline ['branches' ][branch ][exe ]) > len (results ):
364+ results = timeline ['branches' ][branch ][exe ]
365+ end = results [0 ][0 ]
366+ start = results [len (results ) - 1 ][0 ]
367+ timeline ['baseline' ] = [
368+ [str (start ), baselinevalue ],
369+ [str (end ), baselinevalue ]
370+ ]
371+
362372 if append :
363373 timeline_list ['timelines' ].append (timeline )
364374
0 commit comments