Convert to keys and setup feed_item
This commit is contained in:
parent
c3d9dff83f
commit
f0a4e12f2b
8 changed files with 111 additions and 61 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue