Add debug logs to github.rs
All checks were successful
Build and push Docker image / build (push) Successful in 8m5s
Build and push Docker image / deploy (push) Successful in 43s

This commit is contained in:
toast 2024-12-17 19:36:49 +11:00
parent f3fc517d08
commit f87a970067
7 changed files with 13 additions and 15 deletions

6
Cargo.lock generated
View File

@ -1093,7 +1093,7 @@ dependencies = [
[[package]] [[package]]
name = "kon" name = "kon"
version = "0.6.1" version = "0.6.2"
dependencies = [ dependencies = [
"kon_cmds", "kon_cmds",
"kon_libs", "kon_libs",
@ -1122,7 +1122,7 @@ dependencies = [
[[package]] [[package]]
name = "kon_libs" name = "kon_libs"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"cargo_toml", "cargo_toml",
"poise", "poise",
@ -1141,7 +1141,7 @@ dependencies = [
[[package]] [[package]]
name = "kon_tasks" name = "kon_tasks"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"feed-rs", "feed-rs",
"kon_libs", "kon_libs",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kon" name = "kon"
version = "0.6.1" version = "0.6.2"
edition = "2024" edition = "2024"
[workspace] [workspace]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kon_libs" name = "kon_libs"
version = "0.1.0" version = "0.1.1"
edition = "2024" edition = "2024"
[dependencies] [dependencies]

View File

@ -26,7 +26,7 @@ impl ConfigMeta {
Self { Self {
env: "prod".to_string(), env: "prod".to_string(),
embed_color: 0x5A99C7, embed_color: 0x5A99C7,
ready_notify: 865673694184996888, ready_notify: 1268493237912604672,
rss_channel: 865673694184996888, rss_channel: 865673694184996888,
kon_logs: 1268493237912604672, kon_logs: 1268493237912604672,
developers: vec![ developers: vec![

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kon_tasks" name = "kon_tasks"
version = "0.1.0" version = "0.1.1"
edition = "2024" edition = "2024"
[dependencies] [dependencies]

View File

@ -9,6 +9,7 @@ use super::{
parse, parse,
save_to_redis, save_to_redis,
task_err, task_err,
task_info,
trim_old_content trim_old_content
}; };
@ -94,6 +95,7 @@ impl RSSFeed for GitHub {
IncidentColorMap::Default.color() IncidentColorMap::Default.color()
}; };
task_info("RSS:GitHub:Debug", &format!("Checking cache for incident ID: {}", &article.links[0].href));
if cached_incident.is_empty() { if cached_incident.is_empty() {
save_to_redis(rkey, &get_incident_id(&article.links[0].href).unwrap()).await?; save_to_redis(rkey, &get_incident_id(&article.links[0].href).unwrap()).await?;
save_to_redis(&rkey_content, &new_content).await?; save_to_redis(&rkey_content, &new_content).await?;
@ -108,6 +110,7 @@ impl RSSFeed for GitHub {
} else { } else {
redis.set(&rkey_content, &new_content).await.unwrap(); redis.set(&rkey_content, &new_content).await.unwrap();
redis.expire(&rkey_content, 21600).await.unwrap(); redis.expire(&rkey_content, 21600).await.unwrap();
task_info("RSS:GitHub:Debug", "Incident added in cache and preparing to send embed to Discord");
Ok(Some(RSSFeedOutput::IncidentEmbed(embed( Ok(Some(RSSFeedOutput::IncidentEmbed(embed(
color, color,
@ -120,6 +123,7 @@ impl RSSFeed for GitHub {
} else { } else {
save_to_redis(rkey, &incident).await?; save_to_redis(rkey, &incident).await?;
redis.set(&rkey_content, &new_content).await.unwrap(); redis.set(&rkey_content, &new_content).await.unwrap();
task_info("RSS:GitHub:Debug", "Incident updated in cache and preparing to send embed to Discord");
Ok(Some(RSSFeedOutput::IncidentEmbed(embed( Ok(Some(RSSFeedOutput::IncidentEmbed(embed(
color, color,

View File

@ -20,11 +20,7 @@ use {
Http Http
}, },
regex::Regex, regex::Regex,
std::sync::Arc, std::sync::Arc
tokio::time::{
Duration,
sleep
}
}; };
// This is for building up the embed with the feed data // This is for building up the embed with the feed data
@ -79,9 +75,7 @@ async fn process_incident_embed(
message.edit(http, EditMessage::new().embed(embed)).await?; message.edit(http, EditMessage::new().embed(embed)).await?;
} }
sleep(Duration::from_secs(15)).await; if Regex::new(r"(?i)^Resolved\s*-").unwrap().is_match(&new_description) {
if Regex::new(r"(?i)\bresolved\b").unwrap().is_match(&new_description) {
redis.del(redis_key).await?; redis.del(redis_key).await?;
} }
} }