feat: answer atm

This commit is contained in:
Max batleforc 2025-06-04 01:25:39 +02:00
parent 8600ecf7ee
commit 3c8a456b2c
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7
3 changed files with 18 additions and 3 deletions

View File

@ -11,9 +11,12 @@
"gitlens.plusFeatures.enabled": false, "gitlens.plusFeatures.enabled": false,
"editor.guides.bracketPairs": true, "editor.guides.bracketPairs": true,
"cSpell.words": [ "cSpell.words": [
"actix",
"clickhouse", "clickhouse",
"datalake", "datalake",
"openapi",
"utoipa",
"uuid", "uuid",
"Uuid" "Uuid"
], ]
} }

View File

@ -50,7 +50,7 @@ pub async fn init_api(config: Config, pool: Arc<PoolManager>, http: Arc<Http>) -
.bind((Ipv4Addr::UNSPECIFIED, port)) .bind((Ipv4Addr::UNSPECIFIED, port))
.map_err(|e| { .map_err(|e| {
error!("Failed to bind API server: {}", e); error!("Failed to bind API server: {}", e);
})? })?
.run() .run()
.await .await
.map_err(|e| { .map_err(|e| {

View File

@ -5,7 +5,7 @@ use database::{
trivial_question::TrivialQuestion, trivial_question::TrivialQuestion,
trivial_round::TrivialRound, trivial_round::TrivialRound,
}; };
use poise::serenity_prelude::{self as serenity, ActivityData, FullEvent}; use poise::serenity_prelude::{self as serenity, ActivityData, CreateMessage, FullEvent};
use tracing::{info, span, Instrument}; use tracing::{info, span, Instrument};
pub async fn event_handler( pub async fn event_handler(
@ -131,6 +131,18 @@ pub async fn event_handler(
*new_message.timestamp, *new_message.timestamp,
)); ));
inserter.write(&trivia_round.clone()).await?; inserter.write(&trivia_round.clone()).await?;
let optimize = TrivialRound::optimize_table_sql();
match manager_pool.execute_with_retry(&optimize).await {
Ok(_) => {}
Err(e) => {
tracing::error!("Failed to optimize trivia round table: {}", e);
}
}
let builder = CreateMessage::new()
.content("Answer taken into account!")
.reference_message(new_message)
.flags(serenity::MessageFlags::EPHEMERAL);
channel_id.send_message(&ctx.http, builder).await?;
Ok(()) Ok(())
} }
.instrument(span!( .instrument(span!(