DB Schema: Remove episode.published_date column.
This commit is contained in:
parent
963ff212ad
commit
e727734443
@ -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;
|
||||
@ -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;
|
||||
@ -158,7 +158,6 @@ pub(crate) struct NewEpisode {
|
||||
title: String,
|
||||
uri: Option<String>,
|
||||
description: Option<String>,
|
||||
published_date: Option<String>,
|
||||
length: Option<i32>,
|
||||
duration: Option<i32>,
|
||||
guid: Option<String>,
|
||||
@ -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())
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ pub struct Episode {
|
||||
uri: Option<String>,
|
||||
local_uri: Option<String>,
|
||||
description: Option<String>,
|
||||
published_date: Option<String>,
|
||||
epoch: i32,
|
||||
length: Option<i32>,
|
||||
duration: Option<i32>,
|
||||
@ -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())
|
||||
|
||||
@ -71,7 +71,6 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result<NewEpisode> {
|
||||
|
||||
// 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<i32> { item.enclosure().map(|x| x.length().parse().ok())? }();
|
||||
@ -83,7 +82,6 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result<NewEpisode> {
|
||||
.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))
|
||||
|
||||
@ -5,7 +5,6 @@ table! {
|
||||
uri -> Nullable<Text>,
|
||||
local_uri -> Nullable<Text>,
|
||||
description -> Nullable<Text>,
|
||||
published_date -> Nullable<Text>,
|
||||
epoch -> Integer,
|
||||
length -> Nullable<Integer>,
|
||||
duration -> Nullable<Integer>,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user