Getting there.

This commit is contained in:
Jordan Petridis 2017-09-21 06:35:22 +03:00
parent 5187bd1f32
commit 64ed1790ce
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -3,7 +3,7 @@ use diesel;
use schema;
use dbqueries;
use errors::*;
use models::{NewPodcast, NewSource, Source};
use models::{NewEpisode, NewSource, Source};
pub fn foo() {
let inpt = vec![
@ -51,12 +51,23 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> {
let chan = feed.get_podcast_chan(&db)?;
let pd = parse_feeds::parse_podcast(&chan, feed.id())?;
diesel::insert_or_replace(&pd)
.into(schema::podcast::table)
.execute(&db)?;
// Holy shit this works!
let episodes: Vec<_> = chan.items()
.iter()
.map(|x| parse_feeds::parse_episode(x, feed.id()))
.map(|x| parse_feeds::parse_episode(x, feed.id()).unwrap())
.collect();
// lazy invoking the compiler to check for the Vec type :3
// let first: &NewEpisode = episodes.first().unwrap();
diesel::insert_or_replace(&episodes)
.into(schema::episode::table)
.execute(&db)?;
info!("{:#?}", pd);
info!("{:#?}", episodes);
// info!("{:?}", chan);