Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cleanup-ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte committed Sep 1, 2024
2 parents 9d7bc78 + f97dd99 commit 8d95f4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ingestor/chalicelib/speed_restrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import zipfile
import csv
import boto3
from pathlib import PurePath
from datetime import date, datetime
from dataclasses import dataclass
from io import BytesIO, TextIOWrapper
Expand Down Expand Up @@ -87,8 +88,9 @@ def bucket_entries_by_key(entries: Iterator[SpeedRestrictionEntry]) -> Dict[Entr
def csv_is_too_old(csv_file_name: str, max_lookback_months: Union[None, int]) -> bool:
if not max_lookback_months:
return False
csv_date = datetime.strptime(csv_file_name[:7], "%Y-%m").date()
print(csv_date)
file_name_only = PurePath(csv_file_name).name
date_part = file_name_only[:7]
csv_date = datetime.strptime(date_part, "%Y-%m").date()
return (date.today() - csv_date).days > (1 + max_lookback_months) * 30


Expand Down

0 comments on commit 8d95f4c

Please sign in to comment.