Change reminder sending behaviour to keep reminders but flag them as sent
This commit is contained in:
@ -45,7 +45,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
}
|
||||
|
||||
let backlog = sqlx::query!(
|
||||
"SELECT COUNT(1) AS backlog FROM reminders WHERE `utc_time` < NOW() AND enabled = 1"
|
||||
"SELECT COUNT(1) AS backlog FROM reminders WHERE `utc_time` < NOW() AND enabled = 1 AND `status` = 'pending'"
|
||||
)
|
||||
.fetch_one(pool.inner())
|
||||
.await
|
||||
@ -61,6 +61,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
`utc_time` < DATE_ADD(NOW(), INTERVAL 1 DAY) AND
|
||||
`utc_time` >= NOW() AND
|
||||
`enabled` = 1 AND
|
||||
`status` = 'pending' AND
|
||||
`interval_seconds` IS NULL AND
|
||||
`interval_months` IS NULL AND
|
||||
`interval_days` IS NULL
|
||||
@ -80,6 +81,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
WHERE
|
||||
`utc_time` < DATE_ADD(NOW(), INTERVAL 1 DAY) AND
|
||||
`utc_time` >= NOW() AND
|
||||
`status` = 'pending' AND
|
||||
`enabled` = 1 AND (
|
||||
`interval_seconds` IS NOT NULL OR
|
||||
`interval_months` IS NOT NULL OR
|
||||
@ -102,6 +104,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
`utc_time` < DATE_ADD(NOW(), INTERVAL 31 DAY) AND
|
||||
`utc_time` >= NOW() AND
|
||||
`enabled` = 1 AND
|
||||
`status` = 'pending' AND
|
||||
`interval_seconds` IS NULL AND
|
||||
`interval_months` IS NULL AND
|
||||
`interval_days` IS NULL
|
||||
@ -121,6 +124,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
WHERE
|
||||
`utc_time` < DATE_ADD(NOW(), INTERVAL 31 DAY) AND
|
||||
`utc_time` >= NOW() AND
|
||||
`status` = 'pending' AND
|
||||
`enabled` = 1 AND (
|
||||
`interval_seconds` IS NOT NULL OR
|
||||
`interval_months` IS NOT NULL OR
|
||||
@ -169,9 +173,11 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
"SELECT COUNT(1) AS count
|
||||
FROM reminders
|
||||
WHERE
|
||||
`interval_seconds` IS NOT NULL OR
|
||||
`interval_months` IS NOT NULL OR
|
||||
`interval_days` IS NOT NULL"
|
||||
`status` = 'pending' AND (
|
||||
`interval_seconds` IS NOT NULL OR
|
||||
`interval_months` IS NOT NULL OR
|
||||
`interval_days` IS NOT NULL
|
||||
)"
|
||||
)
|
||||
.fetch_one(pool.inner())
|
||||
.await
|
||||
@ -181,6 +187,7 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
||||
"SELECT COUNT(1) AS count
|
||||
FROM reminders
|
||||
WHERE
|
||||
`status` = 'pending' AND
|
||||
`interval_seconds` IS NULL AND
|
||||
`interval_months` IS NULL AND
|
||||
`interval_days` IS NULL"
|
||||
|
@ -362,7 +362,7 @@ pub async fn get_reminders(
|
||||
reminders.utc_time
|
||||
FROM reminders
|
||||
LEFT JOIN channels ON channels.id = reminders.channel_id
|
||||
WHERE FIND_IN_SET(channels.channel, ?)",
|
||||
WHERE `status` = 'pending' AND FIND_IN_SET(channels.channel, ?)",
|
||||
channels
|
||||
)
|
||||
.fetch_all(pool.inner())
|
||||
@ -602,7 +602,7 @@ pub async fn delete_reminder(
|
||||
reminder: Json<DeleteReminder>,
|
||||
pool: &State<Pool<MySql>>,
|
||||
) -> JsonResult {
|
||||
match sqlx::query!("DELETE FROM reminders WHERE uid = ?", reminder.uid)
|
||||
match sqlx::query!("UPDATE reminders SET `status` = 'deleted' WHERE uid = ?", reminder.uid)
|
||||
.execute(pool.inner())
|
||||
.await
|
||||
{
|
||||
|
Reference in New Issue
Block a user