From 6064e8e1d9c461a83eae0897e507924d0f4bf882 Mon Sep 17 00:00:00 2001
From: xqtc <tila@heroin.trade>
Date: Thu, 3 Apr 2025 19:25:02 +0200
Subject: [PATCH] Cleanup

---
 src/db.rs   | 19 ++-----------------
 src/main.rs |  7 -------
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/db.rs b/src/db.rs
index c77b0d1..3409695 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -34,17 +34,6 @@ pub fn create_db() -> Result<()> {
     }
 }
 
-// pub fn query_ingestions() -> Result<Vec<SubstanceEntry>> {
-//     let conn = init_db_conn().unwrap();
-//     let query = "
-//         SELECT * FROM ingestions
-//     ";
-//     let ingestions: Vec<SubstanceEntry> = vec![];
-//     match conn.iterate(query, ) {
-//         Ok(i) => i,
-//         Err(e) => e,
-//     };
-// }
 pub fn get_all_ingestions(conn: &sqlite::Connection) -> Result<Vec<IngestionEntry>> {
     let mut statement = conn.prepare(
         "SELECT substance, route, amount, unit, ingestion_time FROM ingestions ORDER BY ingestion_time DESC"
@@ -57,7 +46,6 @@ pub fn get_all_ingestions(conn: &sqlite::Connection) -> Result<Vec<IngestionEntr
         let route = statement.read::<String, _>("route")?;
         let amount = statement.read::<f64, _>("amount")?;
 
-        // Parse the unit string back to Unit enum
         let unit_str = statement.read::<String, _>("unit")?;
         let unit = match unit_str.as_str() {
             "ug" => Unit::Ug,
@@ -67,17 +55,16 @@ pub fn get_all_ingestions(conn: &sqlite::Connection) -> Result<Vec<IngestionEntr
             _ => continue, // Skip invalid units
         };
 
-        // Parse the ingestion_time string back to DateTime
         let time_str = statement.read::<String, _>("ingestion_time")?;
         let ingestion_time = match chrono::DateTime::parse_from_rfc3339(&time_str) {
             Ok(dt) => dt.with_timezone(&chrono::Local),
-            Err(_) => continue, // Skip invalid dates
+            Err(_) => continue,
         };
 
         let created_str = statement.read::<String, _>("ingestion_time")?;
         let created_at = match chrono::DateTime::parse_from_rfc3339(&created_str) {
             Ok(dt) => Some(dt.with_timezone(&chrono::Local)),
-            Err(_) => continue, // Skip invalid dates
+            Err(_) => continue,
         };
 
         result.push(IngestionEntry {
@@ -94,7 +81,6 @@ pub fn get_all_ingestions(conn: &sqlite::Connection) -> Result<Vec<IngestionEntr
 }
 
 pub fn save_ingestion_to_db(conn: &sqlite::Connection, entry: &IngestionEntry) -> Result<()> {
-    // Prepare the statement with named parameters
     let query = format!(
         "INSERT INTO ingestions (substance, route, amount, unit, ingestion_time, created_at) 
          VALUES ('{}', '{}', {}, '{}', '{}', '{}')",
@@ -106,7 +92,6 @@ pub fn save_ingestion_to_db(conn: &sqlite::Connection, entry: &IngestionEntry) -
         chrono::Local::now().to_rfc3339()
     );
 
-    // Execute the query
     conn.execute(query)?;
 
     Ok(())
diff --git a/src/main.rs b/src/main.rs
index 7d4cea4..f5bef4f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -57,11 +57,6 @@ pub struct IngestionEntry {
 }
 
 fn main() -> Result<(), Box<dyn Error>> {
-    println!("=======");
-    println!("meowlog");
-    println!("=======");
-
-    // Load substances from JSON file
     let substances = match read_substances_from_file() {
         Ok(s) => s,
         Err(e) => {
@@ -89,7 +84,6 @@ fn handle_commands(
         Command::AddIngestion => {
             let ingestion = gather_ingestion_data(substances.clone())?;
 
-            // Display the recorded information
             println!("\nRecorded Information:");
             println!("---------------------");
             println!("Substance: {}", ingestion.entry.substance);
@@ -100,7 +94,6 @@ fn handle_commands(
                 ingestion.entry.ingestion_time.format("%Y-%m-%d %H:%M")
             );
 
-            // Show onset, duration, and after-effects if available
             if let Some(onset) = ingestion.data["formatted_onset"]["value"].as_str() {
                 let unit = ingestion.data["formatted_onset"]["_unit"]
                     .as_str()