diff --git a/hammond-data/migrations/2017-12-30-201631_remove_published_date/down.sql b/hammond-data/migrations/2017-12-30-201631_remove_published_date/down.sql new file mode 100644 index 0000000..e5ec3e3 --- /dev/null +++ b/hammond-data/migrations/2017-12-30-201631_remove_published_date/down.sql @@ -0,0 +1,24 @@ +ALTER TABLE episode RENAME TO old_table; + +CREATE TABLE episode ( + title TEXT NOT NULL, + uri TEXT, + local_uri TEXT, + description TEXT, + published_date TEXT, + epoch INTEGER NOT NULL DEFAULT 0, + length INTEGER, + duration INTEGER, + guid TEXT, + played INTEGER, + podcast_id INTEGER NOT NULL, + favorite INTEGER DEFAULT 0, + archive INTEGER DEFAULT 0, + PRIMARY KEY (title, podcast_id) +); + +INSERT INTO episode (title, uri, local_uri, description, epoch, length, duration, guid, played, favorite, archive, podcast_id) +SELECT title, uri, local_uri, description, epoch, length, duration, guid, played, favorite, archive, podcast_id +FROM old_table; + +Drop table old_table; \ No newline at end of file diff --git a/hammond-data/migrations/2017-12-30-201631_remove_published_date/up.sql b/hammond-data/migrations/2017-12-30-201631_remove_published_date/up.sql new file mode 100644 index 0000000..2723e95 --- /dev/null +++ b/hammond-data/migrations/2017-12-30-201631_remove_published_date/up.sql @@ -0,0 +1,23 @@ +ALTER TABLE episode RENAME TO old_table; + +CREATE TABLE episode ( + title TEXT NOT NULL, + uri TEXT, + local_uri TEXT, + description TEXT, + epoch INTEGER NOT NULL DEFAULT 0, + length INTEGER, + duration INTEGER, + guid TEXT, + played INTEGER, + podcast_id INTEGER NOT NULL, + favorite INTEGER DEFAULT 0, + archive INTEGER DEFAULT 0, + PRIMARY KEY (title, podcast_id) +); + +INSERT INTO episode (title, uri, local_uri, description, epoch, length, duration, guid, played, favorite, archive, podcast_id) +SELECT title, uri, local_uri, description, epoch, length, duration, guid, played, favorite, archive, podcast_id +FROM old_table; + +Drop table old_table; \ No newline at end of file diff --git a/hammond-data/src/models/insertables.rs b/hammond-data/src/models/insertables.rs index 6e6d5b1..8f2689a 100644 --- a/hammond-data/src/models/insertables.rs +++ b/hammond-data/src/models/insertables.rs @@ -158,7 +158,6 @@ pub(crate) struct NewEpisode { title: String, uri: Option, description: Option, - published_date: Option, length: Option, duration: Option, guid: Option, @@ -234,10 +233,6 @@ impl NewEpisode { self.description.as_ref().map(|s| s.as_str()) } - pub(crate) fn published_date(&self) -> Option<&str> { - self.published_date.as_ref().map(|s| s.as_str()) - } - pub(crate) fn guid(&self) -> Option<&str> { self.guid.as_ref().map(|s| s.as_str()) } diff --git a/hammond-data/src/models/queryables.rs b/hammond-data/src/models/queryables.rs index 99672bc..d1a9cc0 100644 --- a/hammond-data/src/models/queryables.rs +++ b/hammond-data/src/models/queryables.rs @@ -30,7 +30,6 @@ pub struct Episode { uri: Option, local_uri: Option, description: Option, - published_date: Option, epoch: i32, length: Option, duration: Option, @@ -92,16 +91,6 @@ impl Episode { self.description = value.map(|x| x.to_string()); } - /// Get the the `published_date`. - pub fn published_date(&self) -> Option<&str> { - self.published_date.as_ref().map(|s| s.as_str()) - } - - /// Set the `published_date`. - pub fn set_published_date(&mut self, value: Option<&str>) { - self.published_date = value.map(|x| x.to_string().to_owned()); - } - /// Get the value of the `description`. pub fn guid(&self) -> Option<&str> { self.guid.as_ref().map(|s| s.as_str()) diff --git a/hammond-data/src/parser.rs b/hammond-data/src/parser.rs index c5e4f4d..0bfa5e9 100644 --- a/hammond-data/src/parser.rs +++ b/hammond-data/src/parser.rs @@ -71,7 +71,6 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result { // Should treat information from the rss feeds as invalid by default. // Case: Thu, 05 Aug 2016 06:00:00 -0400 <-- Actually that was friday. - let pub_date = date.map(|x| x.to_rfc2822()).ok(); let epoch = date.map(|x| x.timestamp() as i32).unwrap_or(0); let length = || -> Option { item.enclosure().map(|x| x.length().parse().ok())? }(); @@ -83,7 +82,6 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result { .description(description) .length(length) .duration(duration) - .published_date(pub_date) .epoch(epoch) .guid(guid) .podcast_id(parent_id) @@ -241,7 +239,6 @@ mod tests { ))) .description(Some(String::from(descr))) .guid(Some(String::from("7df4070a-9832-11e7-adac-cb37b05d5e24"))) - .published_date(Some(String::from("Wed, 13 Sep 2017 10:00:00 +0000"))) .length(Some(66738886)) .epoch(1505296800) .duration(Some(4171)) @@ -269,7 +266,6 @@ mod tests { ))) .description(Some(String::from(descr))) .guid(Some(String::from("7c207a24-e33f-11e6-9438-eb45dcf36a1d"))) - .published_date(Some(String::from("Wed, 9 Aug 2017 10:00:00 +0000"))) .length(Some(67527575)) .epoch(1502272800) .duration(Some(4220)) @@ -296,7 +292,6 @@ mod tests { .description(Some(String::from(descr))) .guid(Some(String::from("https://www.propublica.org/podcast/\ the-breakthrough-hopelessness-exploitation-homes-for-mentally-ill#134472"))) - .published_date(Some(String::from("Fri, 8 Sep 2017 12:00:00 +0000"))) .length(Some(33396551)) .epoch(1504872000) .duration(Some(1670)) @@ -326,7 +321,6 @@ mod tests { "https://www.propublica.\ org/podcast/the-breakthrough-hillary-clinton-failed-presidential-bid#133721", ))) - .published_date(Some(String::from("Fri, 25 Aug 2017 12:00:00 +0000"))) .length(Some(17964071)) .epoch(1503662400) .duration(Some(1125)) @@ -355,7 +349,6 @@ mod tests { ))) .description(Some(String::from(descr))) .guid(Some(String::from("78A682B4-73E8-47B8-88C0-1BE62DD4EF9D"))) - .published_date(Some(String::from("Tue, 12 Sep 2017 22:24:42 -0700"))) .length(Some(46479789)) .epoch(1505280282) .duration(Some(5733)) @@ -381,7 +374,6 @@ mod tests { ))) .description(Some(String::from(descr))) .guid(Some(String::from("1CE57548-B36C-4F14-832A-5D5E0A24E35B"))) - .published_date(Some(String::from("Tue, 5 Sep 2017 20:57:27 -0700"))) .length(Some(36544272)) .epoch(1504670247) .duration(Some(4491)) @@ -411,7 +403,6 @@ mod tests { .guid(Some(String::from( "https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/", ))) - .published_date(Some(String::from("Mon, 28 Aug 2017 15:00:00 -0700"))) .length(Some(15077388)) .epoch(1503957600) .duration(Some(2533)) @@ -437,7 +428,6 @@ mod tests { .guid(Some(String::from( "https://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/", ))) - .published_date(Some(String::from("Tue, 15 Aug 2017 17:00:00 -0700"))) .length(Some(13713219)) .epoch(1502841600) .duration(Some(2313)) diff --git a/hammond-data/src/schema.rs b/hammond-data/src/schema.rs index 6389143..d50a2f5 100644 --- a/hammond-data/src/schema.rs +++ b/hammond-data/src/schema.rs @@ -5,7 +5,6 @@ table! { uri -> Nullable, local_uri -> Nullable, description -> Nullable, - published_date -> Nullable, epoch -> Integer, length -> Nullable, duration -> Nullable,