fix: better job naming for enqueue_doc (#21755)

DocType.method instead of frappe.utils.background_jobs.run_doc_method
This commit is contained in:
Faris Ansari 2023-07-21 11:45:06 +05:30 committed by GitHub
parent fb2ab0b5be
commit ebacca3863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,7 +115,13 @@ class RQJob(Document):
def serialize_job(job: Job) -> frappe._dict:
modified = job.last_heartbeat or job.ended_at or job.started_at or job.created_at
job_name = job.kwargs.get("kwargs", {}).get("job_type") or str(job.kwargs.get("job_name"))
job_kwargs = job.kwargs.get("kwargs", {})
job_name = job_kwargs.get("job_type") or str(job.kwargs.get("job_name"))
if job_name == "frappe.utils.background_jobs.run_doc_method":
doctype = job_kwargs.get("doctype")
doc_method = job_kwargs.get("doc_method")
if doctype and doc_method:
job_name = f"{doctype}.{doc_method}"
# function objects have this repr: '<function functionname at 0xmemory_address >'
# This regex just removes unnecessary things around it.