hammond-data: Delete some dead code.

This commit is contained in:
Jordan Petridis 2018-01-18 17:04:57 +02:00
parent 6abf2535b0
commit 1394366f91
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 9 additions and 52 deletions

View File

@ -8,8 +8,8 @@ use rss;
use dbqueries;
use errors::*;
use models::{Index, IndexState, Update};
use models::{NewEpisode, NewPodcast, Podcast};
use models::{IndexState, Update};
use models::{NewPodcast, Podcast};
use pipeline::*;
#[derive(Debug)]
@ -29,21 +29,7 @@ impl Feed {
/// Index the contents of the RSS `Feed` into the database.
pub fn index(&self) -> Result<()> {
let pd = self.parse_podcast().into_podcast()?;
self.index_channel_items_sync(&pd)
}
// TODO: Refactor transcactions and find a way to do it in parallel.
#[allow(dead_code)]
fn index_channel_items(&self, pd: &Podcast) -> Result<()> {
let episodes = self.parse_channel_items(pd);
episodes.iter().for_each(|x| {
if let Err(err) = x.index() {
error!("Failed to index episode: {:?}.", x.title());
error!("Error msg: {}", err);
};
});
Ok(())
self.index_channel_items(&pd)
}
#[allow(dead_code)]
@ -57,18 +43,7 @@ impl Feed {
}
#[allow(dead_code)]
fn parse_channel_items(&self, pd: &Podcast) -> Vec<NewEpisode> {
let items = self.channel.items();
let new_episodes: Vec<_> = items
.par_iter()
.filter_map(|item| NewEpisode::new(item, pd.id()).ok())
.collect();
new_episodes
}
#[allow(dead_code)]
fn index_channel_items_sync(&self, pd: &Podcast) -> Result<()> {
fn index_channel_items(&self, pd: &Podcast) -> Result<()> {
let items = self.channel.items();
let (insert, update): (Vec<_>, Vec<_>) = items
.into_iter()

View File

@ -101,6 +101,7 @@ impl Index for NewEpisode {
impl NewEpisode {
/// Parses an `rss::Item` into a `NewEpisode` Struct.
#[allow(dead_code)]
pub(crate) fn new(item: &rss::Item, podcast_id: i32) -> Result<Self> {
NewEpisodeMinimal::new(item, podcast_id).map(|ep| ep.into_new_episode(item))
}

View File

@ -13,7 +13,7 @@ use rss;
use Source;
use dbqueries;
use errors::*;
use models::{IndexState, Insert, NewEpisode, NewEpisodeMinimal, Update};
use models::{IndexState, NewEpisode, NewEpisodeMinimal};
// use models::new_episode::NewEpisodeMinimal;
// use Feed;
@ -49,11 +49,8 @@ pub fn pipeline<S: IntoIterator<Item = Source>>(sources: S, ignore_etags: bool)
}
#[allow(dead_code)]
pub(crate) fn determine_episode_state(
ep: NewEpisodeMinimal,
item: &rss::Item,
) -> Result<IndexState<NewEpisode>> {
// determine if feed exists
fn determine_ep_state(ep: NewEpisodeMinimal, item: &rss::Item) -> Result<IndexState<NewEpisode>> {
// Check if feed exists
let exists = dbqueries::episode_exists(ep.title(), ep.podcast_id())?;
if !exists {
@ -70,26 +67,10 @@ pub(crate) fn determine_episode_state(
}
}
#[allow(dead_code)]
pub(crate) fn model_state<T: Insert + Update>(state: IndexState<T>) -> Result<()> {
match state {
IndexState::NotChanged => Ok(()),
IndexState::Index(t) => t.insert(),
IndexState::Update((t, rowid)) => t.update(rowid),
}
}
#[allow(dead_code)]
pub(crate) fn model_state_future<T: Insert + Update>(
state: IndexState<T>,
) -> Box<FutureResult<(), Error>> {
Box::new(result(model_state(state)))
}
#[allow(dead_code)]
pub(crate) fn glue(item: &rss::Item, id: i32) -> Result<IndexState<NewEpisode>> {
let e = NewEpisodeMinimal::new(item, id)?;
determine_episode_state(e, &item)
determine_ep_state(e, &item)
}
// Weird magic from #rust irc channel