mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-26 02:49:16 -04:00
Sort broadcasts by start time
For emails and text messages we sort by the time the user (or API) sent them. This makes sense for broadcasts too, since most users will receive the alert within seconds of it being broadcast. For alerts that haven’t started yet we can sort by `updated_at`, which is when the user preparing the broadcast submitted it for approval.
This commit is contained in:
@@ -42,11 +42,13 @@ class BroadcastMessage(JSONModel):
|
||||
libraries = broadcast_area_libraries
|
||||
|
||||
def __lt__(self, other):
|
||||
return (
|
||||
self.cancelled_at or self.finishes_at or self.created_at
|
||||
) < (
|
||||
other.cancelled_at or other.finishes_at or self.created_at
|
||||
)
|
||||
if self.starts_at and other.starts_at:
|
||||
return self.starts_at < other.starts_at
|
||||
if self.starts_at and not other.starts_at:
|
||||
return True
|
||||
if not self.starts_at and other.starts_at:
|
||||
return False
|
||||
return self.updated_at < other.updated_at
|
||||
|
||||
@classmethod
|
||||
def create(cls, *, service_id, template_id):
|
||||
|
||||
Reference in New Issue
Block a user