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