Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #90 from communitiesuk/fmd-232-email
Browse files Browse the repository at this point in the history
FMD-232: add email to log and report output
  • Loading branch information
gidsg authored Mar 5, 2024
2 parents df3b715 + 22c8357 commit 68123cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def download():
{
"request_type": "download",
"user_id": g.account_id,
"email": g.user.email,
"query_params": query_params,
}
)
Expand Down
9 changes: 8 additions & 1 deletion scripts/extract_download_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
FIELD_NAMES = [
"timestamp",
"user_id",
"email",
"funds",
"file_format",
"organisations",
Expand All @@ -63,9 +64,15 @@ def cloudwatch_logs_to_rows_dict(data: List[dict]) -> List[dict]:
def parse_item(item: dict) -> dict:
message = json.loads([i for i in item if i["field"] == "@message"][0]["value"])
user_id = message["user_id"]
email = message.get("email")
query_params = message["query_params"]
timestamp = [i for i in item if i["field"] == "@timestamp"][0]["value"]
return {"timestamp": timestamp, "user_id": user_id, **query_params}
return {
"timestamp": timestamp,
"user_id": user_id,
"email": email,
**query_params,
}

return [parse_item(item) for item in data]

Expand Down

0 comments on commit 68123cf

Please sign in to comment.