Skip to content

Commit

Permalink
Update logs, class check
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsier committed Jan 9, 2024
1 parent 8eea634 commit 26716b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def handle_upload():

@app.route("/cron/reminders", methods=["GET"])
def handle_reminder():
send_reminders(mail)
send_reminders(mail, app.logger)
return ("", 200)


Expand Down
2 changes: 1 addition & 1 deletion api/computils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def calculate_comps(targ, region, sales_comps, multiplier):
elif region == "cook":
prop_class = targ["property_class"].values[0]
one_story_classes = ["202", "203", "204"]
two_story_classes = ["207", "208", "209"]
two_story_classes = ["205", "206", "207", "208", "209"]
prop_class_query = model.property_class == prop_class
if prop_class in one_story_classes:
prop_class_query = model.property_class.in_(one_story_classes)
Expand Down
9 changes: 6 additions & 3 deletions api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from .email import detroit_reminder_email


def handle_individual_reminder(mail, s3, bucket, key):
def handle_individual_reminder(mail, logger, s3, bucket, key):
logger.info(f"CRON: send_reminders: {key}")
# Load key, check whether it should trigger a reminder, send, then update
obj = s3.get_object(Bucket=bucket, Key=key)
data = json.load(obj["Body"])
Expand All @@ -24,9 +25,11 @@ def handle_individual_reminder(mail, s3, bucket, key):

data["reminder_sent"] = True
s3.put_object(Body=json.dumps(data), Bucket=bucket, Key=key)
logger.info(f"CRON: send_reminders: sent for {key}")


def send_reminders(mail):
def send_reminders(mail, logger):
logger.info("CRON: send reminders")
s3 = boto3.client("s3")
bucket = os.getenv("S3_SUBMISSIONS_BUCKET")
today = datetime.now(pytz.timezone("America/Detroit"))
Expand All @@ -38,7 +41,7 @@ def send_reminders(mail):
)
for obj in res.get("Contents", []):
try:
handle_individual_reminder(mail, s3, bucket, obj["Key"])
handle_individual_reminder(mail, logger, s3, bucket, obj["Key"])
except Exception as e:
sentry_sdk.capture_exception(e)
time.sleep(3)
Expand Down

0 comments on commit 26716b8

Please sign in to comment.