mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-11 21:18:35 +03:00
Rename variables in get_status
There are no logic changes in this commit, just renamed variables so that fewer things are called "result" which seemed confusing. Instead of result.result = task_result.result, we can say response.result = task.result
This commit is contained in:
17
src/main.py
17
src/main.py
@@ -104,22 +104,21 @@ def archive_tasks(archive:schemas.ArchiveCreate, email = Depends(get_bearer_auth
|
||||
@app.get("/tasks/{task_id}")
|
||||
def get_status(task_id, email = Depends(get_bearer_auth)):
|
||||
logger.info(f"status check for user {email}")
|
||||
task_result = AsyncResult(task_id, app=celery)
|
||||
result = {
|
||||
task = AsyncResult(task_id, app=celery)
|
||||
response = {
|
||||
"id": task_id,
|
||||
"status": task_result.status,
|
||||
"result": task_result.result
|
||||
"status": task.status,
|
||||
"result": task.result
|
||||
}
|
||||
try:
|
||||
if task_result.result and "error" in task_result.result:
|
||||
result["status"] = "FAILURE"
|
||||
if task.result and "error" in task.result:
|
||||
response["status"] = "FAILURE"
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error(traceback.format_exc())
|
||||
result["status"] = "FAILURE"
|
||||
response["status"] = "FAILURE"
|
||||
try:
|
||||
json_result = jsonable_encoder(result, exclude_unset=True)
|
||||
return JSONResponse(json_result)
|
||||
return JSONResponse(jsonable_encoder(response, exclude_unset=True))
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user