Skip to content

Commit

Permalink
Set archiving to false by default
Browse files Browse the repository at this point in the history
  • Loading branch information
alexobaseki committed Jun 6, 2024
1 parent b241660 commit 73eea1b
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ def process_import_function(event, context):
if not messages:
return

bucket = messages[0].get("bucket")

for message in messages:
bucket = message.get("bucket")
key = message.get("file_path")
jurisdiction_id = message.get("jurisdiction_id")
jurisdiction_name = message.get("jurisdiction_name")
is_archive_files = message.get("is_archive_files", False)

# for some reason, the key is url encoded sometimes
key = urllib.parse.unquote(key, encoding="utf-8")
Expand Down Expand Up @@ -102,26 +101,26 @@ def process_import_function(event, context):
logger.error(f"Error downloading file: {e}")
all_files.remove(filedir)
continue

# Process imports for all files per jurisdiction in a batch
for abbreviation, juris in unique_jurisdictions.items():
logger.info(f"importing {juris['id']}...")

try:
do_import(juris["id"], f"{datadir}{abbreviation}")
stats.send_last_run(
"last_collection_run_time",
{
"jurisdiction": juris["name"],
"scrape_type": "import",
},
)
archive_files(bucket, juris["keys"])
except Exception as e:
logger.error(
f"Error importing jurisdiction {juris['id']}: {e}"
) # noqa: E501
continue
for abbreviation, juris in unique_jurisdictions.items():
logger.info(f"importing {juris['id']}...")

try:
do_import(juris["id"], f"{datadir}{abbreviation}")
stats.send_last_run(
"last_collection_run_time",
{
"jurisdiction": juris["name"],
"scrape_type": "import",
},
)
if is_archive_files:
archive_files(bucket, juris["keys"])
except Exception as e:
logger.error(
f"Error importing jurisdiction {juris['id']}: {e}"
) # noqa: E501
continue

logger.info(f"{len(all_files)} files processed")
stats.close()
Expand Down

0 comments on commit 73eea1b

Please sign in to comment.