From 286f4273bf87828ff835474d80be0d7168c4df37 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 5 Feb 2025 16:36:18 -0800 Subject: [PATCH] Use Uuid consistently in db methods --- src/poll.rs | 6 +++--- src/poll_utils.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/poll.rs b/src/poll.rs index 7e987cd..97aaf9d 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -26,7 +26,7 @@ pub struct EntryStateUpdate { read: Option, } -async fn read_entries(feed_id: &str, db: &mut SqliteConnection) -> Result, Status> { +async fn read_entries(feed_id: &Uuid, db: &mut SqliteConnection) -> Result, Status> { let rows = sqlx::query!( r#" SELECT @@ -86,13 +86,13 @@ pub async fn poll_feed( feed_id: Uuid, user: AuthenticatedUser, ) -> Result, Status> { - let feed_id = feed_id.to_string(); let user_id = user.user_id.to_string(); + let feed_id_str = feed_id.to_string(); // Get the feed URL from the database, ensuring it belongs to the authenticated user let feed = sqlx::query!( r#"SELECT url, last_checked_time as "last_checked_time: chrono::DateTime" FROM feeds WHERE feed_id = ? AND user_id = ?"#, - feed_id, + feed_id_str, user_id ) .fetch_optional(&mut **db) diff --git a/src/poll_utils.rs b/src/poll_utils.rs index 2ebc1da..fb5ed3f 100644 --- a/src/poll_utils.rs +++ b/src/poll_utils.rs @@ -23,7 +23,6 @@ pub struct Entry { pub marked_read: Option>, } -/// /// Perform the request to fetch from the remote feed url pub async fn fetch_new_entries(url: &Url) -> Result, Status> { let feed_data = fetch_feed(url).await.map_err(|_| Status::BadGateway)?; @@ -53,7 +52,7 @@ pub async fn fetch_new_entries(url: &Url) -> Result, Status> { pub async fn update_entry_db( entries: &Vec, - feed_id: &str, + feed_id: &Uuid, db: &mut SqliteConnection, ) -> Result<(), Status> { // Start a transaction for batch update @@ -65,6 +64,7 @@ pub async fn update_entry_db( let now = Utc::now().to_rfc3339(); // Update the feed's last_checked_time + let feed_id = feed_id.to_string(); sqlx::query!( "UPDATE feeds SET last_checked_time = ? WHERE feed_id = ?", now,