#NEWLINE# def get_chart_data( self , project_id , query_date ) : #NEWLINE# #INDENT# calendar = db . session . query ( func . generate_series ( ( query_date - timedelta ( days = ( CHART_DATA_LIMIT - 1 ) ) ) , query_date , timedelta ( days = 1 ) ) . label ( 'day' ) ) . subquery ( ) #NEWLINE# historical_data = db . session . query ( calendar . c . day , func . coalesce ( func . sum ( FlakyTestStat . flaky_runs ) , 0 ) , func . coalesce ( func . sum ( FlakyTestStat . double_reruns ) , 0 ) , func . coalesce ( func . sum ( FlakyTestStat . passing_runs ) , 0 ) ) . outerjoin ( FlakyTestStat , and_ ( ( calendar . c . day == FlakyTestStat . date ) , ( FlakyTestStat . project_id == project_id ) ) ) . order_by ( calendar . c . day . desc ( ) ) . group_by ( calendar . c . day ) #NEWLINE# chart_data = [ ] #NEWLINE# for ( d , flaky_runs , double_reruns , passing_runs ) in historical_data : #NEWLINE# #INDENT# chart_data . append ( { #NEWLINE# #INDENT# 'date' : str ( d . date ( ) ) , #NEWLINE# 'flaky_runs' : flaky_runs , #NEWLINE# 'double_reruns' : double_reruns , #NEWLINE# 'passing_runs' : self , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return chart_data