Convert to keys and setup feed_item

This commit is contained in:
Julia Lange 2026-02-04 15:49:55 -08:00
parent c3d9dff83f
commit f0a4e12f2b
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
8 changed files with 111 additions and 61 deletions

View file

@ -2,8 +2,8 @@ use crate::{
Result,
AdapterPool,
db::{
ChannelId,
ItemId,
ChannelKey,
ItemKey,
},
fetch::FetchedRSSItem,
};
@ -22,8 +22,8 @@ pub struct UnparsedItem {
impl UnparsedItem {
pub fn parse(self) -> Result<Item> {
Ok(Item {
id: ItemId(self.id),
channel_id: ChannelId(self.channel_id),
id: ItemKey(self.id),
channel_id: ChannelKey(self.channel_id),
fetched_at: match self.fetched_at {
Some(dt_str) => Some(DateTime::parse_from_rfc2822(&dt_str)?
.with_timezone(&Utc)),
@ -38,8 +38,8 @@ impl UnparsedItem {
}
pub struct Item {
id: ItemId,
channel_id: ChannelId,
id: ItemKey,
channel_id: ChannelKey,
#[allow(dead_code)] // TODO: Use for score decay calculations later
fetched_at: Option<DateTime<Utc>>,
@ -49,14 +49,14 @@ pub struct Item {
}
impl Item {
pub fn id(&self) -> ItemId { self.id }
pub fn channel(&self) -> ChannelId { self.channel_id }
pub fn id(&self) -> ItemKey { self.id }
pub fn channel(&self) -> ChannelKey { self.channel_id }
pub fn title(&self) -> Option<&str> { self.title.as_deref() }
pub fn description(&self) -> Option<&str> { self.description.as_deref() }
pub fn content(&self) -> Option<&str> { self.content.as_deref() }
pub async fn get_or_create(
pool: &AdapterPool, from_channel: ChannelId, guid: &str
pool: &AdapterPool, from_channel: ChannelKey, guid: &str
) -> Result<Self> {
let item = sqlx::query_as!(