Milimetric has submitted this change and it was merged. Change subject: making the report results backwards compatible ......................................................................
making the report results backwards compatible Change-Id: I23cd0ece2ca97520f3f1af0648419f42bc3af405 --- M wikimetrics/controllers/reports.py 1 file changed, 11 insertions(+), 2 deletions(-) Approvals: Milimetric: Verified; Looks good to me, approved diff --git a/wikimetrics/controllers/reports.py b/wikimetrics/controllers/reports.py index 7f01ee3..bfc25c6 100644 --- a/wikimetrics/controllers/reports.py +++ b/wikimetrics/controllers/reports.py @@ -82,6 +82,15 @@ return (celery_task, pj) +def get_celery_task_result(celery_task, db_report): + # this indicates an old style result, the celery task result can be returned directly + if db_report.result_key == db_report.queue_result_key: + return celery_task.get() + # otherwise, it's a new style result, the celery task is a dictionary + else: + return celery_task.get()[db_report.result_key] + + @app.route('/reports/status/<result_key>') def report_status(result_key): celery_task, pj = get_celery_task(result_key) @@ -95,7 +104,7 @@ return json_error('no task exists with id: {0}'.format(result_key)) if celery_task.ready(): - task_result = celery_task.get()[result_key] + task_result = get_celery_task_result(celery_task, pj) csv_io = StringIO() if task_result: @@ -157,7 +166,7 @@ return json_error('no task exists with id: {0}'.format(result_key)) if celery_task.ready(): - task_result = celery_task.get()[result_key] + task_result = get_celery_task_result(celery_task, pj) return json_response( result=task_result, -- To view, visit https://gerrit.wikimedia.org/r/79787 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I23cd0ece2ca97520f3f1af0648419f42bc3af405 Gerrit-PatchSet: 1 Gerrit-Project: analytics/wikimetrics Gerrit-Branch: master Gerrit-Owner: Milimetric <dandree...@wikimedia.org> Gerrit-Reviewer: Milimetric <dandree...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits