#NEWLINE# @ property #NEWLINE# def rows( self ) : #NEWLINE# #INDENT# def format_val( val ) : #NEWLINE# #INDENT# return ( self . no_value if ( val is None ) else val ) #NEWLINE# #UNINDENT# def avg( values , idx = None ) : #NEWLINE# #INDENT# sum = 0 #NEWLINE# denom = 0 #NEWLINE# for v in values : #NEWLINE# #INDENT# if ( idx == 10 ) : #NEWLINE# #INDENT# numbers = re . split ( '/|\\s|%' , v [ 'html' ] ) #NEWLINE# sum += int ( numbers [ 0 ] ) #NEWLINE# if ( int ( numbers [ 1 ] ) > denom ) : #NEWLINE# #INDENT# denom = int ( numbers [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# sum += ( v [ 'sort_key' ] if ( v is not None ) else 0 ) #NEWLINE# #UNINDENT# #UNINDENT# mean = ( float ( sum ) / float ( len ( values ) ) ) #NEWLINE# if ( idx == 10 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# percent = ( ( mean * 100 ) / denom ) #NEWLINE# #UNINDENT# except ZeroDivisionError : #NEWLINE# #INDENT# percent = 0 #NEWLINE# #UNINDENT# html = '{0}/{1} ({2}%)' . format ( int ( mean ) , int ( denom ) , int ( percent ) ) #NEWLINE# return format_datatables_data ( html , percent ) #NEWLINE# #UNINDENT# mean = ( '%.0f' % mean ) #NEWLINE# return format_datatables_data ( mean , mean ) #NEWLINE# #UNINDENT# data = [ ] #NEWLINE# config = self . report_config #NEWLINE# for i in range ( 0 , 3 ) : #NEWLINE# #INDENT# config [ 'enddate' ] = ( ( config [ 'startdate' ] + relativedelta ( months = 1 ) ) - relativedelta ( days = 1 ) ) . replace ( hour = 23 , minute = 59 , second = 59 ) #NEWLINE# data . append ( ASHAFacilitatorsData ( config ) . data ) #NEWLINE# config [ 'startdate' ] += relativedelta ( months = 1 ) #NEWLINE# #UNINDENT# rows = [ [ column . header , format_val ( column . get_value ( data [ 2 ] ) ) , format_val ( column . get_value ( data [ 1 ] ) ) , format_val ( column . get_value ( data [ 0 ] ) ) , avg ( [ column . get_value ( data [ 2 ] ) , column . get_value ( data [ 1 ] ) , column . get_value ( data [ 0 ] ) ] , idx ) ] for ( idx , column ) in enumerate ( self . model . columns [ 2 : ] ) ] #NEWLINE# total = [ self . model . columns [ 0 ] . get_raw_value ( d ) for d in data ] #NEWLINE# reporting = [ self . model . columns [ 1 ] . get_raw_value ( d ) for d in data ] #NEWLINE# not_reporting = [ format_datatables_data ( ( i - ( j or 0 ) ) , ( i - ( j or 0 ) ) ) for ( i , j ) in zip ( total , reporting ) ] #NEWLINE# rows . append ( ( ( [ _ ( '<b>Total number of ASHAs who did not report/not known</b>' ) ] + not_reporting ) + [ avg ( not_reporting ) ] ) ) #NEWLINE# return ( rows , ( sum ( total ) / len ( total ) ) )