From 7aedf69839e75a182a0f95411b4315422618b9a8 Mon Sep 17 00:00:00 2001 From: AB Date: Thu, 10 Dec 2020 17:11:09 +0300 Subject: [PATCH] Fix add_conf --- src/db.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/db.rs b/src/db.rs index 58d7b23..716a238 100644 --- a/src/db.rs +++ b/src/db.rs @@ -149,6 +149,7 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> { match get_conf(message.chat.id()) { Ok(_) => { + //info!("Group found: {:?}", message.chat.id()); let update = Conf { id: message.chat.id(), title, @@ -162,9 +163,11 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> { id = :id", )?; stmt.execute_named(&[(":id", &update.id.to_string()), (":title", &update.title)])?; - info!("Conf {:?} updated: {:?}", update.title, get_conf(update.id)); + //info!("Conf {:?} updated: {:?}", update.title, get_conf(update.id)); } Err(_) => { + //info!("Group didn't found: {:?}", message.chat.id()); + let update = Conf { id: message.chat.id(), title, @@ -173,19 +176,16 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> { let unix_time = utils::unixtime().await; let mut stmt = conn.prepare_cached( - "INSERT OR IGNORE INTO conf - SET - title = :title, - date = :date - WHERE - id = :id", + "INSERT OR IGNORE INTO + conf('id', 'title', 'date') + VALUES (:id, :title, :date)", )?; stmt.execute_named(&[ (":id", &update.id.to_string()), (":title", &update.title), (":date", &unix_time), ])?; - //println!("Conf {:?} added: {:?}", update.title, get_conf(update.id)); + //info!("Conf {:?} added: {:?}", update.title, get_conf(update.id)); } } Ok(())