Skip to content

Commit

Permalink
show paused reminders at the end of the list
Browse files Browse the repository at this point in the history
  • Loading branch information
magnickolas committed Nov 19, 2024
1 parent e0395b3 commit 23175a5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "remindee-bot"
version = "0.2.9"
version = "0.2.10"
authors = ["Nikolai Oplachko <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/generic_reminder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}
}

Expand Down

0 comments on commit 23175a5

Please sign in to comment.