Remove stat table
This commit is contained in:
parent
8ba0f02b98
commit
1d64c8bb79
@ -445,30 +445,9 @@ WHERE
|
|||||||
};
|
};
|
||||||
|
|
||||||
error!("[Reminder {}] {}", self.id, message);
|
error!("[Reminder {}] {}", self.id, message);
|
||||||
|
|
||||||
if *LOG_TO_DATABASE {
|
|
||||||
sqlx::query!(
|
|
||||||
"INSERT INTO stat (type, reminder_id, message) VALUES ('reminder_failed', ?, ?)",
|
|
||||||
self.id,
|
|
||||||
message,
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await
|
|
||||||
.expect("Could not log error to database");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn log_success(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
async fn log_success(&self, pool: impl Executor<'_, Database = Database> + Copy) {}
|
||||||
if *LOG_TO_DATABASE {
|
|
||||||
sqlx::query!(
|
|
||||||
"INSERT INTO stat (type, reminder_id) VALUES ('reminder_sent', ?)",
|
|
||||||
self.id,
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await
|
|
||||||
.expect("Could not log success to database");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
||||||
sqlx::query!("UPDATE reminders SET `status` = 'sent' WHERE `id` = ?", self.id)
|
sqlx::query!("UPDATE reminders SET `status` = 'sent' WHERE `id` = ?", self.id)
|
||||||
|
@ -137,38 +137,6 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let history = sqlx::query_as_unchecked!(
|
|
||||||
TimeFrame,
|
|
||||||
"SELECT
|
|
||||||
FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(`utc_time`) / 86400) * 86400) AS `time_key`,
|
|
||||||
COUNT(1) AS `count`
|
|
||||||
FROM stat
|
|
||||||
WHERE
|
|
||||||
`utc_time` > DATE_SUB(NOW(), INTERVAL 31 DAY) AND
|
|
||||||
`type` = 'reminder_sent'
|
|
||||||
GROUP BY `time_key`
|
|
||||||
ORDER BY `time_key`"
|
|
||||||
)
|
|
||||||
.fetch_all(pool.inner())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let history_failed = sqlx::query_as_unchecked!(
|
|
||||||
TimeFrame,
|
|
||||||
"SELECT
|
|
||||||
FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(`utc_time`) / 86400) * 86400) AS `time_key`,
|
|
||||||
COUNT(1) AS `count`
|
|
||||||
FROM stat
|
|
||||||
WHERE
|
|
||||||
`utc_time` > DATE_SUB(NOW(), INTERVAL 31 DAY) AND
|
|
||||||
`type` = 'reminder_failed'
|
|
||||||
GROUP BY `time_key`
|
|
||||||
ORDER BY `time_key`"
|
|
||||||
)
|
|
||||||
.fetch_all(pool.inner())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let interval_count = sqlx::query!(
|
let interval_count = sqlx::query!(
|
||||||
"SELECT COUNT(1) AS count
|
"SELECT COUNT(1) AS count
|
||||||
FROM reminders
|
FROM reminders
|
||||||
@ -206,10 +174,6 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
|
|||||||
"once": schedule_once_long,
|
"once": schedule_once_long,
|
||||||
"interval": schedule_interval_long,
|
"interval": schedule_interval_long,
|
||||||
},
|
},
|
||||||
"historyLong": {
|
|
||||||
"sent": history,
|
|
||||||
"failed": history_failed,
|
|
||||||
},
|
|
||||||
"count": {
|
"count": {
|
||||||
"reminders": reminder_count.count,
|
"reminders": reminder_count.count,
|
||||||
"intervals": interval_count.count,
|
"intervals": interval_count.count,
|
||||||
|
Loading…
Reference in New Issue
Block a user