Add feed sidebar navigation #8
1 changed files with 19 additions and 15 deletions
|
|
@ -108,7 +108,6 @@ impl Db {
|
||||||
if let Some(feed_id) = feed_id {
|
if let Some(feed_id) = feed_id {
|
||||||
query = query.filter(dsl::feed_id.eq(feed_id.to_string()));
|
query = query.filter(dsl::feed_id.eq(feed_id.to_string()));
|
||||||
}
|
}
|
||||||
type Row = (String, String, String, String, String, String, Option<f32>);
|
|
||||||
let rows: Vec<Row> = query
|
let rows: Vec<Row> = query
|
||||||
.order(dsl::final_score.desc())
|
.order(dsl::final_score.desc())
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
@ -123,10 +122,17 @@ impl Db {
|
||||||
))
|
))
|
||||||
.load(&mut conn)
|
.load(&mut conn)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(rows
|
Ok(rows.into_iter().map(RankedArticleRow::from).collect())
|
||||||
.into_iter()
|
}
|
||||||
.map(
|
}
|
||||||
|(id, feed_id, title, url, summary, topics_json, final_score)| RankedArticleRow {
|
|
||||||
|
/// Raw shape of one `list_ranked_articles` row as loaded from SQLite —
|
||||||
|
/// `topics` is still the JSON string column, not yet decoded.
|
||||||
|
type Row = (String, String, String, String, String, String, Option<f32>);
|
||||||
|
|
||||||
|
impl From<Row> for RankedArticleRow {
|
||||||
|
fn from((id, feed_id, title, url, summary, topics_json, final_score): Row) -> Self {
|
||||||
|
Self {
|
||||||
id,
|
id,
|
||||||
feed_id,
|
feed_id,
|
||||||
title,
|
title,
|
||||||
|
|
@ -134,9 +140,7 @@ impl Db {
|
||||||
summary,
|
summary,
|
||||||
topics: serde_json::from_str(&topics_json).unwrap_or_default(),
|
topics: serde_json::from_str(&topics_json).unwrap_or_default(),
|
||||||
final_score,
|
final_score,
|
||||||
},
|
}
|
||||||
)
|
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue