From 14ddb929223076fe2c3332a8eab7a71b8766caf6 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 5 Jan 2024 08:11:35 +1300 Subject: [PATCH] guard against null date --- app/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/utils.py b/app/utils.py index d3ea2eb7..5759c543 100644 --- a/app/utils.py +++ b/app/utils.py @@ -458,11 +458,15 @@ def awaken_dormant_instance(instance): epoch = datetime(1970, 1, 1) + def epoch_seconds(date): td = date - epoch return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000) + def post_ranking(score, date: datetime): + if date is None: + date = datetime.utcnow() order = math.log(max(abs(score), 1), 10) sign = 1 if score > 0 else -1 if score < 0 else 0 seconds = epoch_seconds(date) - 1685766018