diff --git a/src/main.rs b/src/main.rs index 75b34eb..40286b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use db::connect; use html5ever::{parse_document, tendril::TendrilSink, tree_builder::TreeBuilderOpts, ParseOpts}; use rcdom::{Node, RcDom}; use surrealdb::{engine::remote::ws::Client, Surreal}; -use tracing::{debug, info, warn}; +use tracing::{debug, error, info, warn}; mod db; @@ -46,13 +46,14 @@ async fn get(url: &str) -> Rc { async fn walk(node: &rcdom::Handle, db: &Surreal , site_name: &str) { // Insert Or Update - let _created: Vec = match db.upsert("website").content(db::Website { href: String::from("/"), crawled: true, site: site_name.to_string() } ).await { + let _: Option> = match db.upsert(("website", site_name)).content(db::Website { href: String::from("/"), crawled: true, site: site_name.to_string() } ).await { Ok(e) => { // Return this for type coercion e }, Err(e) => { - unimplemented!("{}", e); + // error!("{}", e); + None } }; @@ -68,14 +69,20 @@ async fn walk(node: &rcdom::Handle, db: &Surreal , site_name: &str) { }).await.unwrap(); warn!("{:?}", created) } else { - let href = attr.value.to_string(); - info!("{}", href); - // Every not-mailto link - let _created: Option = db.create("website").content(db::Website { - href, + // FIXME this isn't actually creating records...? + let _: Option = match db.create("website").content(db::Website { + href: attr.value.to_string(), crawled: false, site: site_name.to_string() - }).await.unwrap(); + }).await { + Ok(e) => { + if let Some(a) = &e { + debug!("{:?}", a); + } + e + }, + Err(_) => todo!(), + }; } } };