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
|
|
@ -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!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue