#NEWLINE# def _quickadmin_uses_per_country_by_date( self , query_params , initial_query , group_by ) : #NEWLINE# #INDENT# db_latest_uses_query = initial_query . filter ( ( model . DbUserUsedExperiment . country != None ) ) #NEWLINE# db_latest_uses_query = self . _apply_filters ( db_latest_uses_query , query_params ) #NEWLINE# countries = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for row in db_latest_uses_query . group_by ( * group_by ) . all ( ) : #NEWLINE# #INDENT# country = row [ 0 ] #NEWLINE# count = row [ 1 ] #NEWLINE# key = tuple ( row [ 2 : ] ) #NEWLINE# if ( country not in countries ) : #NEWLINE# #INDENT# countries [ country ] = [ ] #NEWLINE# #UNINDENT# countries [ country ] . append ( ( key , count ) ) #NEWLINE# countries [ country ] . sort ( ( lambda x , y : cmp ( '-' . join ( [ unicode ( v ) . zfill ( 8 ) for v in x [ 0 ] ] ) , '-' . join ( [ unicode ( v ) . zfill ( 8 ) for v in y [ 0 ] ] ) ) ) ) #NEWLINE# #UNINDENT# return countries