From 23175a55ab7d85138d879107a11a3f292e74d422 Mon Sep 17 00:00:00 2001 From: Nikolai Oplachko Date: Tue, 19 Nov 2024 18:19:23 +0100 Subject: [PATCH] show paused reminders at the end of the list --- Cargo.lock | 2 +- Cargo.toml | 2 +- docs/conf.py | 2 +- src/generic_reminder.rs | 14 +++++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59365e4..3848d48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2572,7 +2572,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remindee-bot" -version = "0.2.9" +version = "0.2.10" dependencies = [ "async-std", "async_once", diff --git a/Cargo.toml b/Cargo.toml index 1ef1ef6..e4619f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remindee-bot" -version = "0.2.9" +version = "0.2.10" authors = ["Nikolai Oplachko "] edition = "2021" license = "GPL-3.0-only" diff --git a/docs/conf.py b/docs/conf.py index 4e22cf2..65712f2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ project = "remindee-bot" copyright = "2024, Nikolai Oplachko" author = "Nikolai Oplachko" -release = "0.2.9" +release = "0.2.10" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/src/generic_reminder.rs b/src/generic_reminder.rs index 581410e..db2c6dd 100644 --- a/src/generic_reminder.rs +++ b/src/generic_reminder.rs @@ -51,6 +51,7 @@ pub trait GenericReminder { let chat_id = self.chat_id(); chat_id.is_group() || chat_id.is_channel_or_supergroup() } + fn is_paused(&self) -> bool; } impl GenericReminder for reminder::ActiveModel { @@ -119,6 +120,10 @@ impl GenericReminder for reminder::ActiveModel { fn chat_id(&self) -> ChatId { ChatId(self.chat_id.clone().unwrap()) } + + fn is_paused(&self) -> bool { + self.paused.clone().unwrap() + } } impl GenericReminder for cron_reminder::ActiveModel { @@ -169,11 +174,18 @@ impl GenericReminder for cron_reminder::ActiveModel { fn chat_id(&self) -> ChatId { ChatId(self.chat_id.clone().unwrap()) } + + fn is_paused(&self) -> bool { + self.paused.clone().unwrap() + } } impl Ord for dyn GenericReminder { fn cmp(&self, other: &Self) -> Ordering { - self.get_time().cmp(&other.get_time()) + match self.is_paused().cmp(&other.is_paused()) { + Ordering::Equal => self.get_time().cmp(&other.get_time()), + ord => ord, + } } }