Skip to content

Commit

Permalink
Added more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
keegansmith21 committed Nov 13, 2023
1 parent 149e60a commit 2ad527f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.vscode
*.zip
*.zip
*.pyc
14 changes: 8 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ def download(request):

# download oapen access stats and replace ip addresses
file_path = "/tmp/oapen_access_stats.jsonl.gz"
print(
f"Downloading oapen access stats for month: {release_date}"
)
print(f"Downloading oapen access stats for month: {release_date}")
if datetime.strptime(release_date, "%Y-%m") >= datetime(2020, 4, 1):
print(f"publisher UUID(s): {publisher_uuid_v5}")
entries = download_access_stats_new(file_path, release_date, username, password, publisher_uuid_v5,
geoip_client)
entries = download_access_stats_new(
file_path, release_date, username, password, publisher_uuid_v5, geoip_client
)
else:
print(f"Publisher name(s): {publisher_name_v4}")
entries, unprocessed_publishers = download_access_stats_old(
Expand All @@ -85,10 +84,13 @@ def download(request):

# upload oapen access stats to bucket
success = upload_file_to_storage_bucket(file_path, bucket_name, blob_name)
if not success:
if success:
print(f"Uploaded blob: {blob_name}")
else:
raise RuntimeError("Uploading file to storage bucket unsuccessful")

data = {"entries": entries, "unprocessed_publishers": unprocessed_publishers}
print(f"Returning data: {data}")
return json.dumps(data), 200, {"Content-Type": "application/json"}


Expand Down

0 comments on commit 2ad527f

Please sign in to comment.