#NEWLINE# def main( ) : #NEWLINE# #INDENT# node = models . Node . load ( settings . TABULATE_LOGS_NODE_ID ) #NEWLINE# user = models . User . load ( settings . TABULATE_LOGS_USER_ID ) #NEWLINE# cutoff = ( datetime . datetime . utcnow ( ) - settings . TABULATE_LOGS_TIME_OFFSET ) #NEWLINE# result = run_map_reduce ( query = { #NEWLINE# #INDENT# 'date' : { #NEWLINE# #INDENT# '$gt' : cutoff , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# sio = StringIO ( ) #NEWLINE# utils . make_csv ( sio , ( ( row [ '_id' ] , user [ 'value' ] ) for row in result . find ( ) . sort ( [ ( 'value' , pymongo . DESCENDING ) ] ) ) , [ 'name' , 'count' ] ) #NEWLINE# utils . send_file ( settings . TABULATE_LOGS_FILE_NAME , settings . TABULATE_LOGS_CONTENT_TYPE , sio , node , user )