Skip to content

Commit

Permalink
Merge pull request #206 from hotosm/feature/user_id_tracking
Browse files Browse the repository at this point in the history
Feature : Track user info in exports
  • Loading branch information
kshitijrajsharma authored Jan 23, 2024
2 parents 8e072d1 + a6479d8 commit 31ad637
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion API/custom_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"})
5 changes: 4 additions & 1 deletion API/raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 31ad637

Please sign in to comment.