use crate::api::ArticleView; use anyhow::Result; use feedsignal_db::Db; use uuid::Uuid; /// Returns articles ranked by `final_score` descending, highest-relevance /// first. `feed_id` restricts the list to one feed; `None` joins every /// subscribed feed into one ranked list. pub async fn list_ranked(db: Db, feed_id: Option) -> Result> { let feed_id = feed_id.map(|id| Uuid::parse_str(&id)).transpose()?; Ok(db .list_ranked_articles(feed_id, 100) .await? .into_iter() .map(|row| ArticleView { id: row.id, feed_id: row.feed_id, title: row.title, url: row.url, summary: row.summary, topics: row.topics, final_score: row.final_score, }) .collect()) }