db, add item and functions to get items

Creates item. It's pretty barebowns until I implement fetching.

I also added get functions for feed and channel to get items with.
This commit is contained in:
Julia Lange 2026-02-06 13:03:31 -08:00
parent ac6e71eb62
commit 1c3f4cc854
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
5 changed files with 179 additions and 2 deletions

View file

@ -5,8 +5,10 @@ use crate::{
Channel,
ChannelKey,
FeedKey,
Item,
UserKey,
channel::UnparsedChannel,
item::UnparsedItem,
},
};
@ -77,6 +79,22 @@ impl Feed {
Ok(())
}
pub async fn get_items(
&self, pool: &AdapterPool, limit: u8, offset: u32
) -> Result<Vec<Item>> {
sqlx::query_as!(
UnparsedItem,
"SELECT i.id as `id!`, i.channel_id, i.fetched_at, i.title, i.description,
i.content
FROM items i
JOIN feed_items fi on i.id = fi.item_id
WHERE feed_id = ? AND archived = FALSE
ORDER BY score DESC
LIMIT ? OFFSET ?",
self.key.0, limit, offset
).fetch_all(&pool.0).await?.into_iter().map(UnparsedItem::parse).collect()
}
pub async fn get_channels(
&self, pool: &AdapterPool
) -> Result<Vec<Channel>> {