hammond_data::Feed: add parse_podcast_future method.
This commit is contained in:
parent
7f78e87551
commit
b3460b15a2
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
|
use futures::prelude::*;
|
||||||
|
use futures::future::*;
|
||||||
use rayon::iter::IntoParallelIterator;
|
use rayon::iter::IntoParallelIterator;
|
||||||
|
|
||||||
use rss;
|
use rss;
|
||||||
@ -42,6 +44,17 @@ impl Feed {
|
|||||||
self.index_channel_items(&pd)
|
self.index_channel_items(&pd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Docs
|
||||||
|
// FIXME: docs
|
||||||
|
// FIXME: lifetime stuff
|
||||||
|
pub fn index_future(self) -> Box<Future<Item = (), Error = Error>> {
|
||||||
|
let indx = self.parse_podcast_futture()
|
||||||
|
.and_then(|pd| pd.into_podcast())
|
||||||
|
.and_then(move |pd| self.index_channel_items(&pd));
|
||||||
|
|
||||||
|
Box::new(indx)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Refactor transcactions and find a way to do it in parallel.
|
// TODO: Refactor transcactions and find a way to do it in parallel.
|
||||||
fn index_channel_items(&self, pd: &Podcast) -> Result<()> {
|
fn index_channel_items(&self, pd: &Podcast) -> Result<()> {
|
||||||
let episodes = self.parse_channel_items(pd);
|
let episodes = self.parse_channel_items(pd);
|
||||||
@ -64,6 +77,10 @@ impl Feed {
|
|||||||
parser::new_podcast(&self.channel, self.source_id)
|
parser::new_podcast(&self.channel, self.source_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_podcast_futture(&self) -> Box<FutureResult<NewPodcast, Error>> {
|
||||||
|
Box::new(ok(self.parse_podcast()))
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_channel_items(&self, pd: &Podcast) -> Vec<NewEpisode> {
|
fn parse_channel_items(&self, pd: &Podcast) -> Vec<NewEpisode> {
|
||||||
let items = self.channel.items();
|
let items = self.channel.items();
|
||||||
let new_episodes: Vec<_> = items
|
let new_episodes: Vec<_> = items
|
||||||
|
|||||||
@ -71,6 +71,7 @@ mod parser;
|
|||||||
mod schema;
|
mod schema;
|
||||||
|
|
||||||
pub use models::queryables::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source};
|
pub use models::queryables::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source};
|
||||||
|
// pub use feed::Feed;
|
||||||
|
|
||||||
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
|
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
|
|||||||
@ -716,6 +716,7 @@ impl Source {
|
|||||||
Ok(Feed::from_channel_source(chan, self.id))
|
Ok(Feed::from_channel_source(chan, self.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME:
|
||||||
/// Docs
|
/// Docs
|
||||||
pub fn into_fututre_feed(
|
pub fn into_fututre_feed(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
|
// FIXME:
|
||||||
//! Docs.
|
//! Docs.
|
||||||
|
|
||||||
use errors::Error;
|
|
||||||
use Source;
|
|
||||||
|
|
||||||
use tokio_core::reactor::Core;
|
use tokio_core::reactor::Core;
|
||||||
use hyper::Client;
|
use hyper::Client;
|
||||||
use hyper_tls::HttpsConnector;
|
use hyper_tls::HttpsConnector;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use futures::future::*;
|
use futures::future::*;
|
||||||
|
|
||||||
|
use errors::Error;
|
||||||
|
use Source;
|
||||||
|
// use Feed;
|
||||||
|
|
||||||
// Weird magic from #rust irc channel
|
// Weird magic from #rust irc channel
|
||||||
// kudos to remexre
|
// kudos to remexre
|
||||||
fn collect_futures<F>(
|
fn collect_futures<F>(
|
||||||
@ -60,7 +62,7 @@ mod dirtyhack {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
// FIXME: Make proper indexing futures instead of wrapping up existing
|
// FIXME: Make proper indexing futures instead of wrapping up existing
|
||||||
// blocking functions
|
// blocking functions
|
||||||
.map(|s| s.into_fututre_feed(&client, ignore_etags).map(|feed| feed.index()))
|
.map(|s| s.into_fututre_feed(&client, ignore_etags).map(|feed| feed.index_future()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let f = core.run(collect_futures(list))?;
|
let f = core.run(collect_futures(list))?;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user