diff --git a/migrations/2017-09-15-001128_init_schema/up.sql b/migrations/2017-09-15-001128_init_schema/up.sql index fd07042..77131a6 100644 --- a/migrations/2017-09-15-001128_init_schema/up.sql +++ b/migrations/2017-09-15-001128_init_schema/up.sql @@ -22,8 +22,8 @@ CREATE TABLE `podcast` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, `title` TEXT NOT NULL, `uri` TEXT UNIQUE NOT NULL, - `link` TEXT, - `description` TEXT, + `link` TEXT NOT NULL, + `description` TEXT NOT NULL, `image_uri` TEXT, `source_id` INTEGER NOT NULL ); \ No newline at end of file diff --git a/src/models.rs b/src/models.rs index 238d33e..7c08a38 100644 --- a/src/models.rs +++ b/src/models.rs @@ -31,8 +31,8 @@ pub struct Podcast { id: i32, title: String, uri: String, - link: Option, - description: Option, + link: String, + description: String, image_uri: Option, source_id: i32, } @@ -77,8 +77,8 @@ pub struct NewEpisode<'a> { pub struct NewPodcast { pub title: String, pub uri: String, - pub link: Option, - pub description: Option, + pub link: String, + pub description: String, pub image_uri: Option, } diff --git a/src/parse_feeds.rs b/src/parse_feeds.rs index 0c8246f..74a60a3 100644 --- a/src/parse_feeds.rs +++ b/src/parse_feeds.rs @@ -5,9 +5,9 @@ use errors::*; pub fn parse_podcast(chan: &Channel, uri: &str) -> Result { let title = chan.title().to_owned(); + let link = chan.link().to_owned(); - let link = Some(chan.link().to_owned()); - let description = Some(chan.description().to_owned()); + let description = chan.description().to_owned(); // let image_uri = match chan.image() { // Some(foo) => Some(foo.url().to_owned()), @@ -86,11 +86,8 @@ mod tests { pd.uri, "https://feeds.feedburner.com/InterceptedWithJeremyScahill".to_string() ); - assert_eq!( - pd.link, - Some("https://theintercept.com/podcasts".to_string()) - ); - assert_eq!(pd.description, Some(descr.to_string())); + assert_eq!(pd.link, "https://theintercept.com/podcasts".to_string()); + assert_eq!(pd.description, descr.to_string()); assert_eq!(pd.image_uri, None); @@ -104,11 +101,8 @@ mod tests { let pd = parse_podcast(&channel, uri).unwrap(); assert_eq!(pd.title, "LINUX Unplugged Podcast".to_string()); - assert_eq!( - pd.link, - Some("http://www.jupiterbroadcasting.com/".to_string()) - ); - assert_eq!(pd.description, Some(descr.to_string())); + assert_eq!(pd.link, "http://www.jupiterbroadcasting.com/".to_string()); + assert_eq!(pd.description, descr.to_string()); assert_eq!( pd.image_uri, Some( @@ -132,9 +126,9 @@ mod tests { ); assert_eq!( pd.link, - Some("https://www.propublica.org/feeds/54Ghome".to_string()) + "https://www.propublica.org/feeds/54Ghome".to_string() ); - assert_eq!(pd.description, Some(descr.to_string())); + assert_eq!(pd.description, descr.to_string()); assert_eq!( pd.image_uri, Some( diff --git a/src/schema.rs b/src/schema.rs index 78d401e..d443c46 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -18,8 +18,8 @@ table! { id -> Integer, title -> Text, uri -> Text, - link -> Nullable, - description -> Nullable, + link -> Text, + description -> Text, image_uri -> Nullable, source_id -> Integer, }