Add batch indexing fallback.
If an RSS feed triggered a unique constrains violation, none of it's items would be indexed resulting in a Podcast without episodes. This adds a fallback that indexes each item individually if the batch index fails.
This commit is contained in:
parent
92d01ec51a
commit
d131c279b9
@ -6,7 +6,7 @@ use rss;
|
||||
|
||||
use dbqueries;
|
||||
use errors::*;
|
||||
use models::{IndexState, Update};
|
||||
use models::{Index, IndexState, Update};
|
||||
use models::{NewEpisode, NewPodcast, Podcast};
|
||||
use pipeline::*;
|
||||
|
||||
@ -47,7 +47,16 @@ impl Feed {
|
||||
.and_then(|(insert, update)| {
|
||||
if !insert.is_empty() {
|
||||
info!("Indexing {} episodes.", insert.len());
|
||||
dbqueries::index_new_episodes(insert.as_slice())?;
|
||||
if let Err(err) = dbqueries::index_new_episodes(insert.as_slice()) {
|
||||
error!("Failed batch indexng, Fallign back to individual indexing.");
|
||||
error!("Error: {}", err);
|
||||
insert.iter().for_each(|ep| {
|
||||
if let Err(err) = ep.index() {
|
||||
error!("Failed to index episode: {:?}.", ep.title());
|
||||
error!("Error msg: {}", err);
|
||||
};
|
||||
})
|
||||
}
|
||||
}
|
||||
Ok((insert, update))
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user