diff --git a/hammond-data/migrations/2017-09-15-001128_init_schema/up.sql b/hammond-data/migrations/2017-09-15-001128_init_schema/up.sql index bdd4370..d318f25 100644 --- a/hammond-data/migrations/2017-09-15-001128_init_schema/up.sql +++ b/hammond-data/migrations/2017-09-15-001128_init_schema/up.sql @@ -20,6 +20,7 @@ CREATE TABLE `episode` ( `epoch` INTEGER NOT NULL DEFAULT 0, `length` INTEGER, `guid` TEXT, + `watched` INTEGER , `podcast_id` INTEGER NOT NULL ); diff --git a/hammond-data/src/feedparser.rs b/hammond-data/src/feedparser.rs index e8247f3..586cd5c 100644 --- a/hammond-data/src/feedparser.rs +++ b/hammond-data/src/feedparser.rs @@ -6,6 +6,7 @@ use models; // TODO: look into how bad-utf8 is handled in rss crate, // and figure if there is a need for checking before parsing. // TODO: Extend the support for parsing itunes extensions +/// Parses a rss::Channel into a NewPodcast Struct. pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast { let title = chan.title().trim().to_owned(); let link = chan.link().trim().to_owned(); @@ -29,11 +30,11 @@ pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast { } } +/// Parses a rss::Item into a NewEpisode Struct. pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode { let title = item.title().map(|s| s.trim()); let description = item.description().map(|s| s.trim()); let guid = item.guid().map(|x| x.value().trim()); - let local_uri = None; // Its kinda weird this being an Option type. // Rss 2.0 specified that it's optional. @@ -63,7 +64,6 @@ pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode { models::NewEpisode { title, uri, - local_uri, description, length, published_date: pub_date, diff --git a/hammond-data/src/models.rs b/hammond-data/src/models.rs index 63e9e01..b1b2614 100644 --- a/hammond-data/src/models.rs +++ b/hammond-data/src/models.rs @@ -20,6 +20,7 @@ pub struct Episode { epoch: i32, length: Option, guid: Option, + watched: Option, podcast_id: i32, } @@ -245,7 +246,6 @@ impl<'a> NewSource<'a> { pub struct NewEpisode<'a> { pub title: Option<&'a str>, pub uri: Option<&'a str>, - pub local_uri: Option<&'a str>, pub description: Option<&'a str>, pub published_date: Option, pub length: Option, diff --git a/hammond-data/src/schema.rs b/hammond-data/src/schema.rs index 1f85408..ab5157c 100644 --- a/hammond-data/src/schema.rs +++ b/hammond-data/src/schema.rs @@ -9,6 +9,7 @@ table! { epoch -> Integer, length -> Nullable, guid -> Nullable, + watched -> Nullable, podcast_id -> Integer, } }