Add feed sidebar navigation #8
3 changed files with 5 additions and 17 deletions
|
|
@ -26,21 +26,9 @@ impl Db {
|
|||
Ok(Uuid::parse_str(&id)?)
|
||||
}
|
||||
|
||||
/// All subscribed feeds, for the polling job to iterate over.
|
||||
pub async fn list_feeds(&self) -> Result<Vec<(Uuid, String)>> {
|
||||
use schema::feeds::dsl;
|
||||
let mut conn = self.pool.get().await?;
|
||||
let rows: Vec<(String, String)> = dsl::feeds
|
||||
.select((dsl::id, dsl::url))
|
||||
.load(&mut conn)
|
||||
.await?;
|
||||
rows.into_iter()
|
||||
.map(|(id, url)| Ok((Uuid::parse_str(&id)?, url)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// All subscribed feeds with their titles, for the sidebar's feed list.
|
||||
pub async fn list_feeds_with_titles(&self) -> Result<Vec<(Uuid, String, String)>> {
|
||||
/// All subscribed feeds, ordered by title. Used both by the polling job
|
||||
/// (iterating to fetch each feed) and the sidebar's feed-navigation list.
|
||||
pub async fn list_feeds(&self) -> Result<Vec<(Uuid, String, String)>> {
|
||||
use schema::feeds::dsl;
|
||||
let mut conn = self.pool.get().await?;
|
||||
let rows: Vec<(String, String, String)> = dsl::feeds
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub async fn run(db: &Db) -> Result<()> {
|
|||
let feeds = db.list_feeds().await?;
|
||||
tracing::info!(count = feeds.len(), "polling subscribed feeds");
|
||||
|
||||
for (feed_id, url) in feeds {
|
||||
for (feed_id, _title, url) in feeds {
|
||||
let (_title, articles) = match feedsignal_feeds::fetch_feed(&url, feed_id).await {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ pub async fn subscribe(db: Db, url: String) -> Result<usize> {
|
|||
/// Lists every subscribed feed, for the sidebar's feed-navigation list.
|
||||
pub async fn list(db: Db) -> Result<Vec<FeedView>> {
|
||||
Ok(db
|
||||
.list_feeds_with_titles()
|
||||
.list_feeds()
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|(id, title, url)| FeedView {
|
||||
|
|
|
|||
Loading…
Reference in a new issue