From c9234bcf7251bf1c9bab3c6b45e43b05aa13be69 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Tue, 9 Feb 2021 09:32:07 +0000 Subject: [PATCH] Allow broadcasts which have no created_at to be compared This adds to the `__le__` method on the `BroadcastMessage` class to allow two BroadcastMessages with no `updated_at` to be compared. Previously, the method expected at least one message to have `updated_at` set, but this is not necessarily the case. --- app/models/broadcast_message.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/broadcast_message.py b/app/models/broadcast_message.py index eda45fa53..8c6776e67 100644 --- a/app/models/broadcast_message.py +++ b/app/models/broadcast_message.py @@ -49,6 +49,8 @@ class BroadcastMessage(JSONModel): return self.updated_at < other.created_at if not self.updated_at and other.updated_at: return self.created_at < other.updated_at + if not self.updated_at and not other.updated_at: + return self.created_at < other.created_at return self.updated_at < other.updated_at @classmethod