Database optimizations.
This commit is contained in:
@@ -73,9 +73,7 @@ pub fn refresh_feed(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack, sourc
|
||||
let mut source = source.clone();
|
||||
// TODO: add timeout option and error reporting.
|
||||
thread::spawn(clone!(db => move || {
|
||||
let db_ = db.lock().unwrap();
|
||||
let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source, false);
|
||||
drop(db_);
|
||||
let foo_ = hammond_data::index_feed::refresh_source(&db, &mut source, false);
|
||||
|
||||
if let Ok(x) = foo_ {
|
||||
let Feed(mut req, s) = x;
|
||||
|
||||
@@ -75,6 +75,8 @@ pub fn populate_podcasts_flowbox(
|
||||
stack.remove(&old);
|
||||
stack.add_named(&pdw, "pdw");
|
||||
stack.set_visible_child(&pdw);
|
||||
// aggresive memory cleanup
|
||||
// probably not needed
|
||||
old.destroy();
|
||||
println!("Hello World!, child activated");
|
||||
}));
|
||||
@@ -167,5 +169,8 @@ pub fn update_podcasts_view(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stac
|
||||
stack.add_named(&grid, "pd_grid");
|
||||
// preserve the visible widget
|
||||
stack.set_visible_child_name(&vis);
|
||||
|
||||
// aggresive memory cleanup
|
||||
// probably not needed
|
||||
old.destroy();
|
||||
}
|
||||
|
||||
@@ -168,16 +168,16 @@ fn receive() -> glib::Continue {
|
||||
glib::Continue(false)
|
||||
}
|
||||
|
||||
pub fn episodes_listbox(connection: &Arc<Mutex<SqliteConnection>>, pd_title: &str) -> gtk::ListBox {
|
||||
pub fn episodes_listbox(db: &Arc<Mutex<SqliteConnection>>, pd_title: &str) -> gtk::ListBox {
|
||||
// TODO: handle unwraps.
|
||||
let m = connection.lock().unwrap();
|
||||
let pd = dbqueries::load_podcast_from_title(&m, pd_title).unwrap();
|
||||
let mut episodes = dbqueries::get_pd_episodes(&m, &pd).unwrap();
|
||||
drop(m);
|
||||
let conn = db.lock().unwrap();
|
||||
let pd = dbqueries::load_podcast_from_title(&conn, pd_title).unwrap();
|
||||
let mut episodes = dbqueries::get_pd_episodes(&conn, &pd).unwrap();
|
||||
drop(conn);
|
||||
|
||||
let list = gtk::ListBox::new();
|
||||
episodes.iter_mut().for_each(|ep| {
|
||||
let w = epidose_widget(connection, ep, pd_title);
|
||||
let w = epidose_widget(db, ep, pd_title);
|
||||
list.add(&w)
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
|
||||
use widgets::episode::episodes_listbox;
|
||||
|
||||
pub fn podcast_widget(
|
||||
connection: &Arc<Mutex<SqliteConnection>>,
|
||||
db: &Arc<Mutex<SqliteConnection>>,
|
||||
title: Option<&str>,
|
||||
description: Option<&str>,
|
||||
image: Option<Pixbuf>,
|
||||
@@ -29,7 +29,7 @@ pub fn podcast_widget(
|
||||
|
||||
if let Some(t) = title {
|
||||
title_label.set_text(t);
|
||||
let listbox = episodes_listbox(connection, t);
|
||||
let listbox = episodes_listbox(db, t);
|
||||
view.add(&listbox);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ pub fn on_flowbox_child_activate(
|
||||
stack.remove(&old);
|
||||
stack.add_named(&pdw, "pdw");
|
||||
stack.set_visible_child(&pdw);
|
||||
|
||||
// aggresive memory cleanup
|
||||
// probably not needed
|
||||
old.destroy();
|
||||
println!("Hello World!, child activated");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user