#NEWLINE# @ property #NEWLINE# def drilldown_map( self ) : #NEWLINE# #INDENT# def err_item( val , name , val_count , next_list = None ) : #NEWLINE# #INDENT# ret = { #NEWLINE# #INDENT# 'val' : val , #NEWLINE# 'text' : '{} ({})' . format ( name , val_count ) , #NEWLINE# #UNINDENT# } #NEWLINE# if next_list : #NEWLINE# #INDENT# ret [ 'next' ] = next_list #NEWLINE# #UNINDENT# return ret #NEWLINE# #UNINDENT# data = PillowError . objects . values ( 'pillow' , 'error_type' ) . annotate ( num_errors = Count ( 'id' ) ) #NEWLINE# data_map = defaultdict ( list ) #NEWLINE# pillow_counts = defaultdict ( ( lambda : 0 ) ) #NEWLINE# for row in data : #NEWLINE# #INDENT# pillow = row [ 'pillow' ] #NEWLINE# error = row [ 'error_type' ] #NEWLINE# count = row [ 'num_errors' ] #NEWLINE# data_map [ pillow ] . append ( err_item ( error , error , count ) ) #NEWLINE# pillow_counts [ pillow ] += count #NEWLINE# #UNINDENT# return [ err_item ( pillow , pillow . split ( '.' ) [ ( - 1 ) ] , pillow_counts [ pillow ] , errors ) for ( pillow , errors ) in data_map . items ( ) ]