Removed id function from diesel models.
It's automaticly declared upon derive identifiable, And there's no need to overwrite it.
This commit is contained in:
parent
1bf5187e48
commit
494761beaf
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -271,7 +271,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "diesel_codegen"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/diesel-rs/diesel.git#07f80c3a0d07daa26efff3166fbf0297dc0f0a7b"
|
||||
dependencies = [
|
||||
"diesel 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel_infer_schema 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -548,7 +548,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel 0.16.0 (git+https://github.com/diesel-rs/diesel.git)",
|
||||
"diesel_codegen 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel_codegen 0.16.0 (git+https://github.com/diesel-rs/diesel.git)",
|
||||
"dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -581,6 +581,8 @@ dependencies = [
|
||||
name = "hammond-gtk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"diesel 0.16.0 (git+https://github.com/diesel-rs/diesel.git)",
|
||||
"diesel_codegen 0.16.0 (git+https://github.com/diesel-rs/diesel.git)",
|
||||
"dissolve 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gdk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gdk-pixbuf 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1570,7 +1572,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum derive_builder_core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eed37eae64daa5511467b1a55cebdf472deeaef108d22f62f25e8bbcaffd56ac"
|
||||
"checksum diesel 0.16.0 (git+https://github.com/diesel-rs/diesel.git)" = "<none>"
|
||||
"checksum diesel 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "304226fa7a3982b0405f6bb95dd9c10c3e2000709f194038a60ec2c277150951"
|
||||
"checksum diesel_codegen 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a42ca5c9b660add51d58bc5a50a87123380e1e458069c5504528a851ed7384"
|
||||
"checksum diesel_codegen 0.16.0 (git+https://github.com/diesel-rs/diesel.git)" = "<none>"
|
||||
"checksum diesel_infer_schema 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf1957ff5cd3b04772e43c162c2f69c2aa918080ff9b020276792d236be8be52"
|
||||
"checksum dissolve 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "898542be4716d992082c8e4fc331b792d626cfa71cb2b4790f828b9a8f921a90"
|
||||
"checksum dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d6f0e2bb24d163428d8031d3ebd2d2bd903ad933205a97d0f18c7c1aade380f3"
|
||||
|
||||
@ -18,11 +18,13 @@ xdg = "2.1.0"
|
||||
|
||||
[dependencies.diesel]
|
||||
features = ["sqlite"]
|
||||
# version = "0.16.0"
|
||||
git = "https://github.com/diesel-rs/diesel.git"
|
||||
|
||||
[dependencies.diesel_codegen]
|
||||
features = ["sqlite"]
|
||||
version = "0.16.0"
|
||||
# version = "0.16.0"
|
||||
git = "https://github.com/diesel-rs/diesel.git"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.3.18"
|
||||
|
||||
@ -127,8 +127,8 @@ pub fn remove_feed(db: &Database, pd: &Podcast) -> QueryResult<usize> {
|
||||
|
||||
tempdb.transaction(|| -> QueryResult<usize> {
|
||||
delete_source(&tempdb, pd.source_id())?;
|
||||
delete_podcast(&tempdb, pd.id())?;
|
||||
delete_podcast_episodes(&tempdb, pd.id())
|
||||
delete_podcast(&tempdb, *pd.id())?;
|
||||
delete_podcast_episodes(&tempdb, *pd.id())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use rayon::prelude::*;
|
||||
use diesel::Identifiable;
|
||||
|
||||
use rss;
|
||||
|
||||
@ -38,7 +39,7 @@ impl Feed {
|
||||
}
|
||||
|
||||
fn index_channel(&self, db: &Database) -> Result<Podcast> {
|
||||
let pd = parser::new_podcast(&self.channel, self.source.id());
|
||||
let pd = parser::new_podcast(&self.channel, *self.source.id());
|
||||
// Convert NewPodcast to Podcast
|
||||
pd.into_podcast(db)
|
||||
}
|
||||
@ -49,7 +50,7 @@ impl Feed {
|
||||
fn index_channel_items(&self, db: &Database, pd: &Podcast) -> Result<()> {
|
||||
let it = self.channel.items();
|
||||
let episodes: Vec<_> = it.par_iter()
|
||||
.map(|x| parser::new_episode(x, pd.id()))
|
||||
.map(|x| parser::new_episode(x, *pd.id()))
|
||||
.collect();
|
||||
|
||||
episodes.into_par_iter().for_each(|x| {
|
||||
|
||||
@ -39,10 +39,6 @@ pub struct Episode {
|
||||
}
|
||||
|
||||
impl Episode {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn title(&self) -> Option<&str> {
|
||||
self.title.as_ref().map(|s| s.as_str())
|
||||
}
|
||||
@ -173,10 +169,6 @@ impl From<NewPodcast> for Podcast {
|
||||
}
|
||||
|
||||
impl Podcast {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn source_id(&self) -> i32 {
|
||||
self.source_id
|
||||
}
|
||||
@ -251,10 +243,6 @@ pub struct Source {
|
||||
}
|
||||
|
||||
impl<'a> Source {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn uri(&self) -> &str {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
@ -20,6 +20,16 @@ rayon = "0.9.0"
|
||||
features = ["v3_22"]
|
||||
version = "0.2.0"
|
||||
|
||||
[dependencies.diesel]
|
||||
features = ["sqlite"]
|
||||
# version = "0.16.0"
|
||||
git = "https://github.com/diesel-rs/diesel.git"
|
||||
|
||||
[dependencies.diesel_codegen]
|
||||
features = ["sqlite"]
|
||||
# version = "0.16.0"
|
||||
git = "https://github.com/diesel-rs/diesel.git"
|
||||
|
||||
[dependencies.hammond-data]
|
||||
path = "../hammond-data"
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ extern crate gio;
|
||||
extern crate glib;
|
||||
extern crate gtk;
|
||||
|
||||
// extern crate diesel;
|
||||
extern crate diesel;
|
||||
extern crate dissolve;
|
||||
extern crate hammond_data;
|
||||
extern crate hammond_downloader;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use gtk;
|
||||
use gtk::prelude::*;
|
||||
use gdk_pixbuf::Pixbuf;
|
||||
use diesel::associations::Identifiable;
|
||||
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::Podcast;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
use open;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::{Episode, Podcast};
|
||||
@ -8,6 +7,7 @@ use hammond_data::utils::*;
|
||||
use hammond_data::errors::*;
|
||||
|
||||
use dissolve::strip_html_tags;
|
||||
use diesel::associations::Identifiable;
|
||||
|
||||
use std::thread;
|
||||
use std::cell::RefCell;
|
||||
@ -71,7 +71,7 @@ fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::
|
||||
|
||||
play_button.connect_clicked(
|
||||
clone!(db, episode, played_button, unplayed_button => move |_| {
|
||||
on_play_bttn_clicked(&db, episode.id());
|
||||
on_play_bttn_clicked(&db, *episode.id());
|
||||
let _ = set_played_now(&db, &mut episode.clone());
|
||||
played_button.hide();
|
||||
unplayed_button.show();
|
||||
@ -80,7 +80,7 @@ fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::
|
||||
|
||||
delete_button.connect_clicked(
|
||||
clone!(episode, db, play_button, download_button => move |del| {
|
||||
on_delete_bttn_clicked(&db, episode.id());
|
||||
on_delete_bttn_clicked(&db, *episode.id());
|
||||
del.hide();
|
||||
play_button.hide();
|
||||
download_button.show();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user