Got the structure; got lots of tests; item still needs work

This commit is contained in:
Julia Lange 2026-01-22 10:39:38 -08:00
parent d7123fb153
commit 7bb4cf4230
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
5 changed files with 338 additions and 88 deletions

View file

@ -1,6 +1,7 @@
use crate::{
Result,
Item,
item::UnparsedItem,
Channel,
channel::{
UnparsedChannel,
@ -77,10 +78,11 @@ impl Feed {
pub async fn add_channel(
&self, pool: &SqlitePool, channel_id: ChannelId
) -> Result<()> {
let int_channel_id = i64::from(channel_id);
sqlx::query!(
"INSERT INTO feed_channels (feed_id, channel_id)
VALUES (?, ?)",
self.id.0, channel_id.0
self.id.0, int_channel_id
).execute(pool).await?;
Ok(())
@ -89,16 +91,16 @@ impl Feed {
pub async fn get_items(
&self, pool: &SqlitePool, limit: u8, offset: u32
) -> Result<Vec<Item>> {
let items = sqlx::query_as!(
Item,
let items: Result<Vec<Item>> = sqlx::query_as!(
UnparsedItem,
"SELECT item_id as id FROM feed_items
WHERE feed_id = ? AND archived = FALSE
ORDER BY score DESC
LIMIT ? OFFSET ?",
self.id.0, limit, offset
).fetch_all(pool).await?;
).fetch_all(pool).await?.into_iter().map(UnparsedItem::parse).collect();
Ok(items)
items
}
pub async fn get_channels(