Skip to content

Commit

Permalink
Merge pull request #127 from dod-advana/UOT-143953
Browse files Browse the repository at this point in the history
UOT-143953
  • Loading branch information
rha930 authored May 17, 2022
2 parents 63c81aa + 7c972d3 commit 267615e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gamechangerml/api/fastapi/routers/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tarfile
import shutil
import threading
import pandas as pd

from datetime import datetime
from gamechangerml import DATA_PATH
Expand Down Expand Up @@ -1018,11 +1019,19 @@ async def get_user_data(data_dict: dict, response: Response):
Returns:
confirmation of data download
"""
data = data_dict["params"]["data"]

userData = data_dict["params"]["userData"]
GC_USER_DATA = os.path.join(
DATA_PATH, "user_data", "search_history", "UserAggregations.json"
)
with open(GC_USER_DATA, "w") as f:
json.dump(data, f)
json.dump(userData, f)

searchData = data_dict["params"]["searchData"]
df = pd.DataFrame(searchData)
GC_SEARCH_DATA = os.path.join(
DATA_PATH, "user_data", "search_history","SearchPdfMapping.csv"
)
df.to_csv(GC_SEARCH_DATA)

return f"wrote {len(data)} user data to file"
return f"wrote {len(userData)} user data and searches to file"

0 comments on commit 267615e

Please sign in to comment.