#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# db = get_db ( ) #NEWLINE# while True : #NEWLINE# #INDENT# results = db . view ( 'doc_conflicts/conflicts' , reduce = False , limit = options [ 'batch' ] , include_docs = True , conflicts = True ) #NEWLINE# total = results . total_rows #NEWLINE# if ( not total ) : #NEWLINE# #INDENT# logger . info ( 'Document conflict deletion complete' ) #NEWLINE# return #NEWLINE# #UNINDENT# logger . info ( 'Processing {} of {} docs' . format ( len ( results ) , total ) ) #NEWLINE# to_delete = [ ] #NEWLINE# for row in results : #NEWLINE# #INDENT# doc = row [ 'doc' ] #NEWLINE# conflicts = doc . get ( '_conflicts' , [ ] ) #NEWLINE# doc_id = doc [ '_id' ] #NEWLINE# logger . info ( 'Deleting {} conflicts for doc: {}' . format ( len ( conflicts ) , doc_id ) ) #NEWLINE# for rev in conflicts : #NEWLINE# #INDENT# to_delete . append ( { #NEWLINE# #INDENT# '_id' : doc_id , #NEWLINE# '_rev' : rev , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( len ( to_delete ) > 100 ) : #NEWLINE# #INDENT# bulk_delete ( db , total ) #NEWLINE# to_delete = [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# bulk_delete ( db , to_delete )