Added extra columns to podcast and episode tables.

This commit is contained in:
Jordan Petridis 2017-11-15 16:58:21 +02:00
parent 8b4701f1a1
commit 118846f255
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 61 additions and 2 deletions

View File

@ -16,11 +16,13 @@ CREATE TABLE `episode` (
`uri` TEXT NOT NULL UNIQUE,
`local_uri` TEXT,
`description` TEXT,
`published_date` TEXT ,
`published_date` TEXT,
`epoch` INTEGER NOT NULL DEFAULT 0,
`length` INTEGER,
`guid` TEXT,
`played` INTEGER ,
`played` INTEGER,
`favorite` INTEGER NOT NULL DEFAULT 0,
`archive` INTEGER NOT NULL DEFAULT 0,
`podcast_id` INTEGER NOT NULL
);
@ -30,5 +32,8 @@ CREATE TABLE `podcast` (
`link` TEXT NOT NULL,
`description` TEXT NOT NULL,
`image_uri` TEXT,
`favorite` INTEGER NOT NULL DEFAULT 0,
`archive` INTEGER NOT NULL DEFAULT 0,
`always_dl` INTEGER NOT NULL DEFAULT 0,
`source_id` INTEGER NOT NULL
);

View File

@ -25,6 +25,8 @@ pub struct Episode {
guid: Option<String>,
/// Represent the epoch value of when the episode was last played.
played: Option<i32>,
favorite: bool,
archive: bool,
podcast_id: i32,
}
@ -106,6 +108,22 @@ impl Episode {
self.played = value;
}
pub fn archive(&self) -> bool {
self.archive
}
pub fn set_archive(&mut self, b: bool) {
self.archive = b
}
pub fn favorite(&self) -> bool {
self.favorite
}
pub fn set_favorite(&mut self, b: bool) {
self.favorite = b
}
pub fn save(&self, db: &Database) -> QueryResult<Episode> {
let tempdb = db.lock().unwrap();
self.save_changes::<Episode>(&*tempdb)
@ -123,6 +141,9 @@ pub struct Podcast {
link: String,
description: String,
image_uri: Option<String>,
favorite: bool,
archive: bool,
always_dl: bool,
source_id: i32,
}
@ -163,6 +184,30 @@ impl Podcast {
self.image_uri = value.map(|x| x.to_string());
}
pub fn archive(&self) -> bool {
self.archive
}
pub fn set_archive(&mut self, b: bool) {
self.archive = b
}
pub fn favorite(&self) -> bool {
self.favorite
}
pub fn set_favorite(&mut self, b: bool) {
self.favorite = b
}
pub fn always_download(&self) -> bool {
self.always_dl
}
pub fn set_always_download(&mut self, b: bool) {
self.always_dl = b
}
pub fn save(&self, db: &Database) -> QueryResult<Podcast> {
let tempdb = db.lock().unwrap();
self.save_changes::<Podcast>(&*tempdb)
@ -277,6 +322,7 @@ pub struct NewPodcast {
}
impl NewPodcast {
// This is meant only to be used to make unit tests easier.
pub fn into_podcast(self) -> Podcast {
Podcast {
id: 0,
@ -285,6 +331,9 @@ impl NewPodcast {
description: self.description,
image_uri: self.image_uri,
source_id: self.source_id,
always_dl: false,
archive: false,
favorite: false,
}
}
}

View File

@ -10,6 +10,8 @@ table! {
length -> Nullable<Integer>,
guid -> Nullable<Text>,
played -> Nullable<Integer>,
favorite -> Bool,
archive -> Bool,
podcast_id -> Integer,
}
}
@ -21,6 +23,9 @@ table! {
link -> Text,
description -> Text,
image_uri -> Nullable<Text>,
favorite -> Bool,
archive -> Bool,
always_dl -> Bool,
source_id -> Integer,
}
}