perf: reduce failed_error_log size

This commit is contained in:
Gavin D'souza 2020-04-27 13:42:00 +05:30
parent 82e7a9de28
commit 0805307514

View File

@ -575,11 +575,14 @@ class TallyMigration(Document):
if isinstance(data, frappe.model.document.Document):
if sys.exc_info()[1].__class__ != frappe.DuplicateEntryError:
failed_import_log = json.loads(self.failed_import_log)
doc = data.as_dict()
doc_fields = { x.fieldname for x in frappe.get_doc("DocType", doc.doctype).fields }
stripped_doc = { k: v for k, v in doc.items() if k in doc_fields }
failed_import_log.append({
"doc": data.as_dict(),
"doc": stripped_doc,
"exc": traceback.format_exc()
})
self.failed_import_log = json.dumps(failed_import_log)
self.failed_import_log = json.dumps(failed_import_log, separators=(',', ':'))
self.save()
else:
data = data or self.status