<s> from sqlalchemy . dialects . postgresql import JSONB <EOL> from aleph . core import db <EOL> from aleph . model . common import DatedModel <EOL> CRAWL = '<STR_LIT>' <EOL> INGEST = '<STR_LIT>' <EOL> ANALYZE = '<STR_LIT>' <EOL> INDEX = '<STR_LIT:index>' <EOL> class ProcessingLog ( db . Model , DatedModel ) : <EOL> """<STR_LIT>""" <EOL> id = db . Column ( db . BigInteger , primary_key = True ) <EOL> operation = db . Column ( db . Unicode , nullable = True , index = True ) <EOL> component = db . Column ( db . Unicode , nullable = True , index = True ) <EOL> source_location = db . Column ( db . Unicode , nullable = True , index = True ) <EOL> content_hash = db . Column ( db . Unicode ( <NUM_LIT> ) , nullable = True , index = True ) <EOL> foreign_id = db . Column ( db . Unicode , unique = False , nullable = True ) <EOL> source_id = db . Column ( db . Integer , nullable = True ) <EOL> document_id = db . Column ( db . BigInteger , nullable = True ) <EOL> meta = db . Column ( JSONB ) <EOL> error_type = db . Column ( db . Unicode , nullable = True ) <EOL> error_message = db . Column ( db . Unicode , nullable = True ) <EOL> error_details = db . Column ( db . Unicode , nullable = True ) <EOL> @ classmethod <EOL> def log ( cls , operation , component = None , source_location = None , <EOL> content_hash = None , foreign_id = None , source_id = None , <EOL> document_id = None , meta = None , error_type = None , <EOL> error_message = None , error_details = None ) : <EOL> meta = meta or { } <EOL> obj = ProcessingLog ( ) <EOL> obj . operation = operation <EOL> obj . component = component <EOL> obj . source_id = source_id <EOL> obj . document_id = document_id <EOL> obj . meta = meta <EOL> source_location = source_location or meta . get ( '<STR_LIT>' ) or meta . get ( '<STR_LIT>' ) or meta . get ( '<STR_LIT>' ) <EOL> obj . source_location = source_location <EOL> obj . content_hash = content_hash or meta . get ( '<STR_LIT>' ) <EOL> obj . foreign_id = foreign_id or meta . get ( '<STR_LIT>' ) <EOL> obj . error_type = error_type <EOL> obj . error_message = error_message <EOL> obj . error_details = error_details <EOL> session = db . create_scoped_session ( ) <EOL> session . add ( obj ) <EOL> session . commit ( ) <EOL> session . remove ( ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . id , self . content_hash ) <EOL> def __unicode__ ( self ) : <EOL> return self . id </s>
