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

@ -4,7 +4,7 @@ use crate::{
Result,
AdapterPool,
db::{
ChannelId,
ChannelKey,
Item,
FeedChannel,
feed_channel::UnparsedFeedChannel,
@ -23,7 +23,7 @@ pub struct UnparsedChannel {
impl UnparsedChannel {
pub fn parse(self) -> Result<Channel> {
Ok(Channel {
id: ChannelId(self.id),
id: ChannelKey(self.id),
title: self.title,
link: Url::parse(&self.link)?,
description: self.description,
@ -36,7 +36,7 @@ impl UnparsedChannel {
}
pub struct Channel {
id: ChannelId,
id: ChannelKey,
title: String,
link: Url,
description: Option<String>,
@ -44,7 +44,7 @@ pub struct Channel {
}
impl Channel {
pub fn id(&self) -> ChannelId { self.id }
pub fn id(&self) -> ChannelKey { self.id }
pub fn title(&self) -> &str { &self.title }
pub fn link(&self) -> &Url { &self.link }
pub fn description(&self) -> Option<&str> { self.description.as_deref() }
@ -59,7 +59,7 @@ impl Channel {
channels
}
pub async fn get(pool: &AdapterPool, id: ChannelId) -> Result<Self> {
pub async fn get(pool: &AdapterPool, id: ChannelKey) -> Result<Self> {
let channel: Result<Self> = sqlx::query_as!(
UnparsedChannel,
"SELECT id, title, link, description, last_fetched