From a6479d8353b108420bede158989d650e5c2fc9c8 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Tue, 23 Jan 2024 10:39:08 +0545 Subject: [PATCH] Adds user in kwargs to keep track services using raw data api --- API/api_worker.py | 4 ++-- API/custom_exports.py | 5 ++++- API/raw_data.py | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/API/api_worker.py b/API/api_worker.py index aafa6a31..a71965bc 100644 --- a/API/api_worker.py +++ b/API/api_worker.py @@ -49,7 +49,7 @@ time_limit=DEFAULT_HARD_TASK_LIMIT, soft_time_limit=DEFAULT_SOFT_TASK_LIMIT, ) -def process_raw_data(self, params): +def process_raw_data(self, params, user=None): params = RawDataCurrentParams(**params) try: start_time = time.time() @@ -209,7 +209,7 @@ def process_raw_data(self, params): time_limit=HDX_HARD_TASK_LIMIT, soft_time_limit=HDX_SOFT_TASK_LIMIT, ) -def process_custom_request(self, params): +def process_custom_request(self, params, user=None): params = DynamicCategoriesModel(**params) if not params.dataset: diff --git a/API/custom_exports.py b/API/custom_exports.py index 72fbe74e..2e8d955c 100644 --- a/API/custom_exports.py +++ b/API/custom_exports.py @@ -809,6 +809,9 @@ async def process_custom_requests( status_code=400, detail=[{"msg": "Categories can't be empty"}] ) task = process_custom_request.apply_async( - args=(params.model_dump(),), queue=queue_name, track_started=True + args=(params.model_dump(),), + queue=queue_name, + track_started=True, + kwargs={"user": user.model_dump()}, ) return JSONResponse({"task_id": task.id, "track_link": f"/tasks/status/{task.id}/"}) diff --git a/API/raw_data.py b/API/raw_data.py index c6f8a41a..db40ac02 100644 --- a/API/raw_data.py +++ b/API/raw_data.py @@ -443,7 +443,10 @@ def get_osm_current_snapshot_as_file( # queue_name = "raw_special" if not params.uuid else "raw_default" queue_name = "raw_default" # Everything directs to default now task = process_raw_data.apply_async( - args=(params.model_dump(),), queue=queue_name, track_started=True + args=(params.model_dump(),), + queue=queue_name, + track_started=True, + kwargs={"user": user.model_dump()}, ) return JSONResponse( {