From 7d8748e3ef6cdfdaf368f4bfbe0223c68909b527 Mon Sep 17 00:00:00 2001 From: jude Date: Fri, 19 Aug 2022 09:04:12 +0100 Subject: [PATCH] group by channel instead of guild --- postman/src/sender.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/postman/src/sender.rs b/postman/src/sender.rs index b2ee3be..d4f4246 100644 --- a/postman/src/sender.rs +++ b/postman/src/sender.rs @@ -292,22 +292,21 @@ INNER JOIN ON reminders.channel_id = channels.id WHERE - reminders.id IN ( + reminders.`id` IN ( SELECT - MIN(reminders.id) - FROM reminders - INNER JOIN - channels - ON reminders.channel_id = channels.id - WHERE reminders.`utc_time` < NOW() - GROUP BY channels.guild_id + MIN(id) + FROM + reminders + WHERE + reminders.`utc_time` <= NOW() + AND ( + reminders.`interval_seconds` IS NOT NULL + OR reminders.`interval_months` IS NOT NULL + OR reminders.enabled + ) + GROUP BY channel_id ) - AND reminders.`utc_time` < NOW() - AND ( - reminders.`interval_seconds` IS NOT NULL - OR reminders.`interval_months` IS NOT NULL - OR reminders.enabled - )"#, + "#, ) .fetch_all(pool) .await