feedsignal/crates/web/src/server/services/articles.rs
Austin Schaefer 73c80491be
All checks were successful
CI / check (pull_request) Successful in 1m34s
CI / test (pull_request) Successful in 3m19s
CI / audit (pull_request) Successful in 12s
Turn RankedArticleRow into a struct instead of a 7-field tuple
Tuples this large stop being readable at the call site (positional
indices like rows[0].6 give no hint what they mean); a named struct
documents each field and lets rustc catch reordering mistakes.
2026-09-03 21:20:41 +02:00

25 lines
816 B
Rust

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<String>) -> Result<Vec<ArticleView>> {
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())
}