Use Uuid consistently in db methods
This commit is contained in:
parent
241bb3fba4
commit
286f4273bf
@ -26,7 +26,7 @@ pub struct EntryStateUpdate {
|
||||
read: Option<bool>,
|
||||
}
|
||||
|
||||
async fn read_entries(feed_id: &str, db: &mut SqliteConnection) -> Result<Vec<Entry>, Status> {
|
||||
async fn read_entries(feed_id: &Uuid, db: &mut SqliteConnection) -> Result<Vec<Entry>, Status> {
|
||||
let rows = sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
@ -86,13 +86,13 @@ pub async fn poll_feed(
|
||||
feed_id: Uuid,
|
||||
user: AuthenticatedUser,
|
||||
) -> Result<Json<FeedPollResponse>, 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<chrono::Utc>" FROM feeds WHERE feed_id = ? AND user_id = ?"#,
|
||||
feed_id,
|
||||
feed_id_str,
|
||||
user_id
|
||||
)
|
||||
.fetch_optional(&mut **db)
|
||||
|
@ -23,7 +23,6 @@ pub struct Entry {
|
||||
pub marked_read: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
///
|
||||
/// Perform the request to fetch from the remote feed url
|
||||
pub async fn fetch_new_entries(url: &Url) -> Result<Vec<Entry>, 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<Vec<Entry>, Status> {
|
||||
|
||||
pub async fn update_entry_db(
|
||||
entries: &Vec<Entry>,
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user