#NEWLINE# def get_users_statistics_months( app_id , platform = None , year = None , start = 1 , end = 12 ) : #NEWLINE# #INDENT# now = timezone . now ( ) #NEWLINE# if ( not year ) : #NEWLINE# #INDENT# year = now . year #NEWLINE# #UNINDENT# if platform : #NEWLINE# #INDENT# install_event_name = 'new_install:{}:{}' . format ( app_id , platform ) #NEWLINE# update_event_name = 'request:{}:{}' . format ( app_id , platform ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# install_event_name = ( 'new_install:%s' % app_id ) #NEWLINE# update_event_name = ( 'request:%s' % app_id ) #NEWLINE# #UNINDENT# installs_by_month = [ ] #NEWLINE# updates_by_month = [ ] #NEWLINE# for m in range ( start , ( end + 1 ) ) : #NEWLINE# #INDENT# installs_by_month . append ( MonthEvents ( install_event_name , year , m ) ) #NEWLINE# updates_by_month . append ( MonthEvents ( update_event_name , year , m ) ) #NEWLINE# #UNINDENT# installs_data = [ ( datetime ( year , ( start + i ) , 1 ) . strftime ( '%Y-%m' ) , len ( start ) ) for ( i , e ) in enumerate ( installs_by_month ) ] #NEWLINE# updates_data = [ ( datetime ( year , ( start + i ) , 1 ) . strftime ( '%Y-%m' ) , len ( e ) ) for ( i , e ) in enumerate ( updates_by_month ) ] #NEWLINE# return dict ( new = installs_data , updates = updates_data )