#NEWLINE# def _get_status_counts( self , cutoff ) : #NEWLINE# #INDENT# excluded = [ Status . finished , Status . collecting_results , Status . unknown ] #NEWLINE# build_stats = dict ( db . session . query ( Build . status , func . count ( ) ) . filter ( ( Build . date_created >= cutoff ) , ( ~ Build . status . in_ ( excluded ) ) ) . group_by ( Build . status ) ) #NEWLINE# job_stats = dict ( db . session . query ( Job . status , func . count ( ) ) . filter ( ( Job . date_created >= cutoff ) , ( ~ Job . status . in_ ( excluded ) ) ) . group_by ( Job . status ) ) #NEWLINE# jobstep_stats = dict ( db . session . query ( JobStep . status , func . count ( ) ) . filter ( ( JobStep . date_created >= cutoff ) , ( ~ JobStep . status . in_ ( excluded ) ) ) . group_by ( JobStep . status ) ) #NEWLINE# context = [ ] #NEWLINE# for status in Status . __members__ . values ( ) : #NEWLINE# #INDENT# if ( status in excluded ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( status == Status . pending_allocation ) : #NEWLINE# #INDENT# name = 'Pending Allocation' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name = unicode ( status ) #NEWLINE# #UNINDENT# context . append ( { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'numBuilds' : build_stats . get ( status , 0 ) , #NEWLINE# 'numJobs' : job_stats . get ( status , 0 ) , #NEWLINE# 'numJobSteps' : jobstep_stats . get ( status , 0 ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return context