Add feed sidebar navigation #8
4 changed files with 21 additions and 11 deletions
|
|
@ -14,6 +14,13 @@ A change is done when all of the following hold, not just when it compiles.
|
|||
- Within `db`, one file per domain concern (`feeds.rs`, `articles.rs`,
|
||||
`reading_events.rs`, `affinities.rs`) — a new table gets its own file,
|
||||
not a growing `queries.rs`.
|
||||
- Data-model structs (domain models, query row types, DTOs/views) live in
|
||||
a crate's `models.rs` rather than the file that produces or consumes
|
||||
them, whenever a struct is used outside the function that builds it —
|
||||
matching the existing `crates/core/src/models.rs` pattern. This doesn't
|
||||
apply to structs that are inherently local to one file/component (e.g.
|
||||
a Dioxus component's `Props`/`Styles`/context struct, or a helper
|
||||
struct scoped to a single function's internals).
|
||||
|
||||
## DRY, but not premature
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::models::RankedArticleRow;
|
||||
use crate::schema;
|
||||
use crate::Db;
|
||||
use anyhow::Result;
|
||||
|
|
@ -7,17 +8,6 @@ use diesel_async::RunQueryDsl;
|
|||
use feedsignal_core::Article;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// One row of [`Db::list_ranked_articles`].
|
||||
pub struct RankedArticleRow {
|
||||
pub id: String,
|
||||
pub feed_id: String,
|
||||
pub title: String,
|
||||
pub url: String,
|
||||
pub summary: String,
|
||||
pub topics: Vec<String>,
|
||||
pub final_score: Option<f32>,
|
||||
}
|
||||
|
||||
impl Db {
|
||||
pub async fn insert_article(&self, article: &Article) -> Result<()> {
|
||||
use schema::articles::dsl;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
mod affinities;
|
||||
mod articles;
|
||||
mod feeds;
|
||||
mod models;
|
||||
mod reading_events;
|
||||
|
||||
pub use models::RankedArticleRow;
|
||||
pub(crate) mod schema;
|
||||
|
||||
use anyhow::Result;
|
||||
|
|
|
|||
10
crates/db/src/models.rs
Normal file
10
crates/db/src/models.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/// One row of [`crate::Db::list_ranked_articles`].
|
||||
pub struct RankedArticleRow {
|
||||
pub id: String,
|
||||
pub feed_id: String,
|
||||
pub title: String,
|
||||
pub url: String,
|
||||
pub summary: String,
|
||||
pub topics: Vec<String>,
|
||||
pub final_score: Option<f32>,
|
||||
}
|
||||
Loading…
Reference in a new issue