Pull in feeds on demo startup
This commit is contained in:
parent
08994856c3
commit
d7882b0291
@ -64,5 +64,5 @@
|
|||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "2bbed6f20243ced25ac9359afefafb5ddffdff949250e0e4e35bf399fc0199fc"
|
"hash": "6186c55b12f42931e31a9f8367d6aa2bd637091ca9e1b8d9459241ca9488882c"
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ struct DemoFeed {
|
|||||||
category: Option<&'static str>,
|
category: Option<&'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEMO_FEEDS: [DemoFeed; 5] = [
|
const DEMO_FEEDS: [DemoFeed; 6] = [
|
||||||
DemoFeed {
|
DemoFeed {
|
||||||
name: "XKCD",
|
name: "XKCD",
|
||||||
url: "https://xkcd.com/atom.xml",
|
url: "https://xkcd.com/atom.xml",
|
||||||
@ -31,6 +31,11 @@ const DEMO_FEEDS: [DemoFeed; 5] = [
|
|||||||
url: "https://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml",
|
url: "https://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml",
|
||||||
category: Some("News"),
|
category: Some("News"),
|
||||||
},
|
},
|
||||||
|
DemoFeed {
|
||||||
|
name: "Lines and Colors",
|
||||||
|
url: "https://linesandcolors.com/feed/",
|
||||||
|
category: None,
|
||||||
|
},
|
||||||
DemoFeed {
|
DemoFeed {
|
||||||
name: "Astronomy Picture of the Day (APOD)",
|
name: "Astronomy Picture of the Day (APOD)",
|
||||||
url: "https://apod.nasa.gov/apod.rss",
|
url: "https://apod.nasa.gov/apod.rss",
|
||||||
@ -106,7 +111,7 @@ pub async fn setup_demo_data(pool: &sqlx::SqlitePool) {
|
|||||||
"Successfully fetched {} entries",
|
"Successfully fetched {} entries",
|
||||||
entries.len()
|
entries.len()
|
||||||
);
|
);
|
||||||
if let Err(e) = update_entry_db(&entries, &feed_id, &*pool).await {
|
if let Err(e) = update_entry_db(&entries, &feed_id, pool).await {
|
||||||
warn!(error=%e, feed_url=url.as_str(), "Failed to store entries in database");
|
warn!(error=%e, feed_url=url.as_str(), "Failed to store entries in database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ pub struct EntryStateUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn read_entries(feed_id: &Uuid, db: &mut SqliteConnection) -> Result<Vec<Entry>, Status> {
|
async fn read_entries(feed_id: &Uuid, db: &mut SqliteConnection) -> Result<Vec<Entry>, Status> {
|
||||||
|
let feed_id_str = feed_id.to_string();
|
||||||
let rows = sqlx::query!(
|
let rows = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
SELECT
|
SELECT
|
||||||
@ -44,7 +45,7 @@ async fn read_entries(feed_id: &Uuid, db: &mut SqliteConnection) -> Result<Vec<E
|
|||||||
ORDER BY published DESC NULLS LAST
|
ORDER BY published DESC NULLS LAST
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
"#,
|
"#,
|
||||||
feed_id,
|
feed_id_str,
|
||||||
MAX_ENTRIES_PER_FEED,
|
MAX_ENTRIES_PER_FEED,
|
||||||
)
|
)
|
||||||
.fetch_all(db)
|
.fetch_all(db)
|
||||||
|
Loading…
Reference in New Issue
Block a user