<s> import logging <EOL> from aleph . core import db <EOL> from aleph . model import Entity <EOL> from aleph . index import index_entity , delete_entity <EOL> from aleph . analyze import analyze_entity <EOL> log = logging . getLogger ( __name__ ) <EOL> def update_entity ( entity ) : <EOL> """<STR_LIT>""" <EOL> if entity . deleted_at : <EOL> delete_entity ( entity . id ) <EOL> else : <EOL> index_entity ( entity ) <EOL> analyze_entity . delay ( entity . id ) <EOL> def reindex_entities ( ) : <EOL> query = db . session . query ( Entity ) <EOL> for entity in query . yield_per ( <NUM_LIT:1000> ) : <EOL> log . info ( '<STR_LIT>' , entity . id , entity . name ) <EOL> if entity . deleted_at : <EOL> delete_entity ( entity . id ) <EOL> else : <EOL> index_entity ( entity ) </s>
