EpisodeView: Initial refactor to make loading non-blocking.

This commit is contained in:
Jordan Petridis
2018-04-19 02:52:58 +03:00
parent f811a9c8f4
commit 0e4430bae4
3 changed files with 74 additions and 77 deletions
+14
View File
@@ -349,6 +349,20 @@ pub(crate) fn episode_exists(title_: &str, podcast_id_: i32) -> Result<bool, Dat
.map_err(From::from)
}
/// Check `episode` table empty
///
/// Return true if `episode` table is populated.
pub fn is_episodes_populated() -> Result<bool, DataError> {
use schema::episode::dsl::*;
let db = connection();
let con = db.get()?;
select(exists(episode.count()))
.get_result(&con)
.map_err(From::from)
}
pub(crate) fn index_new_episodes(eps: &[NewEpisode]) -> Result<(), DataError> {
use schema::episode::dsl::*;
let db = connection();