Skip to content

Commit 041a6fd

Browse files
committed
Update of the API for traceback_histories
1 parent 941edbf commit 041a6fd

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

mrq/dashboard/app.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,27 @@ def api_job_result(job_id):
286286
@app.route('/api/job/<job_id>/traceback')
287287
@requires_auth
288288
def api_job_traceback(job_id):
289-
collection = connections.mongodb_jobs.mrq_jobs
289+
collection = connections.mongodb_jobs.mrq_jobss
290+
if get_current_config().get("save_traceback_history"):
291+
292+
field_sent = "traceback_history"
293+
else:
294+
field_sent = "traceback"
295+
290296
job_data = collection.find_one(
291-
{"_id": ObjectId(job_id)}, projection=["traceback"])
297+
{"_id": ObjectId(job_id)}, projection=[field_sent])
292298

293299
if not job_data:
294-
job_data = {}
300+
# If a job has no traceback history, we fallback onto traceback
301+
if field_sent == "traceback_history":
302+
field_sent = "traceback"
303+
job_data = collection.find_one(
304+
{"_id": ObjectId(job_id)}, projection=[field_sent])
305+
if not job_data:
306+
job_data = {}
295307

296308
return jsonify({
297-
"traceback": job_data.get("traceback", "No exception raised")
309+
field_sent: job_data.get(field_sent, "No exception raised")
298310
})
299311

300312

0 commit comments

Comments
 (0)