#NEWLINE# @ functools . wraps ( _original_methods [ 'refresh' ] ) #NEWLINE# def _cursor_refresh( cursor_self ) : #NEWLINE# #INDENT# def privar( name ) : #NEWLINE# #INDENT# return getattr ( cursor_self , '_Cursor__{0}' . format ( name ) ) #NEWLINE# #UNINDENT# is_getmore = ( privar ( 'id' ) is not None ) #NEWLINE# start_time = time . time ( ) #NEWLINE# result = _original_methods [ 'refresh' ] ( cursor_self ) #NEWLINE# total_time = ( ( time . time ( ) - start_time ) * 1000 ) #NEWLINE# query_son = privar ( 'query_spec' ) ( ) #NEWLINE# __traceback_hide__ = True #NEWLINE# query_data = { #NEWLINE# #INDENT# 'time' : total_time , #NEWLINE# 'operation' : 'find' , #NEWLINE# 'stack_trace' : _get_stacktrace ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# if is_getmore : #NEWLINE# #INDENT# query_data [ 'cursor' ] = id ( cursor_self ) #NEWLINE# query_data [ 'operation' ] = 'getmore' #NEWLINE# queries . append ( query_data ) #NEWLINE# return result #NEWLINE# #UNINDENT# collection_name = privar ( 'collection' ) #NEWLINE# query_data [ 'collection' ] = collection_name . full_name . split ( '.' ) [ 1 ] #NEWLINE# if ( query_data [ 'collection' ] == '$cmd' ) : #NEWLINE# #INDENT# query_son = query_son . get ( '$query' , query_son ) #NEWLINE# query_data [ 'operation' ] = 'command' #NEWLINE# if ( 'count' in query_son ) : #NEWLINE# #INDENT# query_data [ 'collection' ] = query_son [ 'count' ] #NEWLINE# query_data [ 'operation' ] = 'count' #NEWLINE# query_data [ 'skip' ] = query_son . get ( 'skip' ) #NEWLINE# query_data [ 'limit' ] = abs ( query_son . get ( 'limit' , 0 ) ) #NEWLINE# query_data [ 'query' ] = query_son [ 'query' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'aggregate' in query_son ) : #NEWLINE# #INDENT# query_data [ 'collection' ] = query_son [ 'aggregate' ] #NEWLINE# query_data [ 'operation' ] = 'aggregate' #NEWLINE# query_data [ 'query' ] = query_son [ 'pipeline' ] #NEWLINE# query_data [ 'skip' ] = 0 #NEWLINE# query_data [ 'limit' ] = None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# query_data [ 'skip' ] = privar ( 'skip' ) #NEWLINE# query_data [ 'limit' ] = abs ( ( privar ( 'limit' ) or 0 ) ) #NEWLINE# query_data [ 'query' ] = ( query_son . get ( '$query' ) or query_son ) #NEWLINE# query_data [ 'ordering' ] = _get_ordering ( query_son ) #NEWLINE# query_data [ 'cursor' ] = id ( cursor_self ) #NEWLINE# #UNINDENT# queries . append ( query_data ) #NEWLINE# return result