From f5f0a5b87305e44acd9968cc8f5d1cb31b6a10ec Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 14 Apr 2018 07:52:55 +0300 Subject: [PATCH] Remove dead code. --- hammond-data/src/dbqueries.rs | 14 ++++++++++- hammond-data/src/errors.rs | 2 -- hammond-data/src/pipeline.rs | 44 ----------------------------------- 3 files changed, 13 insertions(+), 47 deletions(-) diff --git a/hammond-data/src/dbqueries.rs b/hammond-data/src/dbqueries.rs index 81305c3..008f7cf 100644 --- a/hammond-data/src/dbqueries.rs +++ b/hammond-data/src/dbqueries.rs @@ -381,15 +381,27 @@ mod tests { use database::*; use pipeline::*; + use hyper::Client; + use hyper_tls::HttpsConnector; + use tokio_core::reactor::Core; + + use num_cpus; + #[test] fn test_update_none_to_played_now() { truncate_db().unwrap(); + let mut core = Core::new().unwrap(); + let handle = core.handle(); + let client = Client::configure() + .connector(HttpsConnector::new(num_cpus::get(), &handle).unwrap()) + .build(&handle); + let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\ com/InterceptedWithJeremyScahill"; let source = Source::from_url(url).unwrap(); let id = source.id(); - index_single_source(source, true).unwrap(); + pipeline(vec![source], true, &mut core, client).unwrap(); let pd = get_podcast_from_source_id(id).unwrap(); let eps_num = get_pd_unplayed_episodes(&pd).unwrap().len(); diff --git a/hammond-data/src/errors.rs b/hammond-data/src/errors.rs index 9054ef3..6a0dd21 100644 --- a/hammond-data/src/errors.rs +++ b/hammond-data/src/errors.rs @@ -57,8 +57,6 @@ pub enum DataError { F301(Source), #[fail(display = "Error occured while Parsing an Episode. Reason: {}", reason)] ParseEpisodeError { reason: String, parent_id: i32 }, - #[fail(display = "No Futures where produced to be run.")] - EmptyFuturesList, #[fail(display = "Episode was not changed and thus skipped.")] EpisodeNotChanged, } diff --git a/hammond-data/src/pipeline.rs b/hammond-data/src/pipeline.rs index 4edbddb..f72abda 100644 --- a/hammond-data/src/pipeline.rs +++ b/hammond-data/src/pipeline.rs @@ -81,22 +81,6 @@ pub fn run(sources: Vec, ignore_etags: bool) -> Result<(), DataError> { pipeline(sources, ignore_etags, &mut core, client) } -/// Docs -pub fn index_single_source(s: Source, ignore_etags: bool) -> Result<(), DataError> { - let mut core = Core::new()?; - let handle = core.handle(); - - let client = Client::configure() - .connector(HttpsConnector::new(num_cpus::get(), &handle)?) - .build(&handle); - - let work = s.into_feed(client, ignore_etags) - .and_then(move |feed| feed.index()) - .map(|_| ()); - - core.run(work) -} - fn determine_ep_state( ep: NewEpisodeMinimal, item: &rss::Item, @@ -127,34 +111,6 @@ pub(crate) fn glue_async<'a>( ) } -// Weird magic from #rust irc channel -// kudos to remexre -/// FIXME: Docs -#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] -pub fn collect_futures( - futures: Vec, -) -> Box>, Error = DataError>> -where - F: 'static + Future, - ::Item: 'static, - ::Error: 'static, -{ - Box::new(loop_fn((futures, vec![]), |(futures, mut done)| { - select_all(futures).then(|r| { - let (r, rest) = match r { - Ok((r, _, rest)) => (Ok(r), rest), - Err((r, _, rest)) => (Err(r), rest), - }; - done.push(r); - if rest.is_empty() { - Ok(Loop::Break(done)) - } else { - Ok(Loop::Continue((rest, done))) - } - }) - })) -} - #[cfg(test)] mod tests { use super::*;