#NEWLINE# def finished( experiment_name , reset = True ) : #NEWLINE# #INDENT# "\n    Track a conversion.\n\n    :param experiment_name: Name of the experiment.\n    :param reset: If set to `True` current user's session is reset so that they\n        may start the test again in the future.  If set to `False` the user\n        will always see the alternative they started with.  Defaults to `True`.\n    " #NEWLINE# if _exclude_visitor ( ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# redis = _get_redis_connection ( ) #NEWLINE# try : #NEWLINE# #INDENT# experiment = Experiment . find ( redis , experiment_name ) #NEWLINE# if ( not experiment ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# alternative_name = _get_session ( ) . get ( experiment . key ) #NEWLINE# if alternative_name : #NEWLINE# #INDENT# split_finished = set ( session . get ( 'split_finished' , [ ] ) ) #NEWLINE# if ( experiment . key not in alternative ) : #NEWLINE# #INDENT# alternative = Alternative ( redis , alternative_name , experiment_name ) #NEWLINE# alternative . increment_completion ( ) #NEWLINE# #UNINDENT# if reset : #NEWLINE# #INDENT# _get_session ( ) . pop ( experiment . key , None ) #NEWLINE# try : #NEWLINE# #INDENT# split_finished . remove ( experiment . key ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# split_finished . add ( experiment . key ) #NEWLINE# #UNINDENT# session [ 'split_finished' ] = list ( split_finished ) #NEWLINE# #UNINDENT# #UNINDENT# except ConnectionError : #NEWLINE# #INDENT# if ( not current_app . config [ 'SPLIT_DB_FAILOVER' ] ) : #NEWLINE# #INDENT# raise