Methods renaming, Api changes.
This commit is contained in:
parent
9bc6df2cba
commit
31328355b1
@ -1,5 +1,5 @@
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use diesel::Identifiable;
|
use diesel::{Identifiable, QueryResult};
|
||||||
use rss;
|
use rss;
|
||||||
|
|
||||||
use dbqueries;
|
use dbqueries;
|
||||||
@ -16,7 +16,7 @@ pub struct Feed {
|
|||||||
|
|
||||||
impl Feed {
|
impl Feed {
|
||||||
pub fn from_source(s: Source) -> Result<Feed> {
|
pub fn from_source(s: Source) -> Result<Feed> {
|
||||||
s.refresh()
|
s.into_feed()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_channel_source(chan: rss::Channel, s: Source) -> Feed {
|
pub fn from_channel_source(chan: rss::Channel, s: Source) -> Feed {
|
||||||
@ -27,16 +27,19 @@ impl Feed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn index(&self) -> Result<()> {
|
fn index(&self) -> Result<()> {
|
||||||
let pd = self.index_channel()?;
|
let pd = self.get_podcast()?;
|
||||||
|
|
||||||
self.index_channel_items(&pd)?;
|
self.index_channel_items(&pd)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_channel(&self) -> Result<Podcast> {
|
pub fn index_channel(&self) -> QueryResult<()> {
|
||||||
let pd = parser::new_podcast(&self.channel, *self.source.id());
|
let new_pd = parser::new_podcast(&self.channel, *self.source.id());
|
||||||
// Convert NewPodcast to Podcast
|
new_pd.index()
|
||||||
pd.into_podcast()
|
}
|
||||||
|
|
||||||
|
pub fn get_podcast(&self) -> Result<Podcast> {
|
||||||
|
parser::new_podcast(&self.channel, *self.source.id()).into_podcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Refactor transcactions and find a way to do it in parallel.
|
// TODO: Refactor transcactions and find a way to do it in parallel.
|
||||||
|
|||||||
@ -91,7 +91,7 @@ impl NewPodcast {
|
|||||||
Ok(dbqueries::get_podcast_from_title(&self.title)?)
|
Ok(dbqueries::get_podcast_from_title(&self.title)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn index(&self) -> QueryResult<()> {
|
pub fn index(&self) -> QueryResult<()> {
|
||||||
let pd = dbqueries::get_podcast_from_title(&self.title);
|
let pd = dbqueries::get_podcast_from_title(&self.title);
|
||||||
|
|
||||||
match pd {
|
match pd {
|
||||||
|
|||||||
@ -277,7 +277,7 @@ impl<'a> Source {
|
|||||||
self.save_changes::<Source>(&*tempdb)
|
self.save_changes::<Source>(&*tempdb)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh(mut self) -> Result<Feed> {
|
pub fn into_feed(mut self) -> Result<Feed> {
|
||||||
use reqwest::header::{ETag, EntityTag, Headers, HttpDate, LastModified};
|
use reqwest::header::{ETag, EntityTag, Headers, HttpDate, LastModified};
|
||||||
|
|
||||||
let mut headers = Headers::new();
|
let mut headers = Headers::new();
|
||||||
|
|||||||
@ -208,9 +208,9 @@ mod tests {
|
|||||||
fn test_cache_image() {
|
fn test_cache_image() {
|
||||||
let pd = Source::from_url("http://www.newrustacean.com/feed.xml")
|
let pd = Source::from_url("http://www.newrustacean.com/feed.xml")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.refresh()
|
.into_feed()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.index_channel()
|
.get_podcast()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let img_path = cache_image(&pd);
|
let img_path = cache_image(&pd);
|
||||||
|
|||||||
@ -125,9 +125,9 @@ mod tests {
|
|||||||
fn test_get_pixbuf_from_path() {
|
fn test_get_pixbuf_from_path() {
|
||||||
let pd = Source::from_url("http://www.newrustacean.com/feed.xml")
|
let pd = Source::from_url("http://www.newrustacean.com/feed.xml")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.refresh()
|
.into_feed()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.index_channel()
|
.get_podcast()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let pxbuf = get_pixbuf_from_path(&pd);
|
let pxbuf = get_pixbuf_from_path(&pd);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user