Skip to content

Commit

Permalink
Print GUI - Cache database queries for reuse.
Browse files Browse the repository at this point in the history
This allows users to hit a slow-down when cycling between weeks, but
going back to the same week will hit the cache.

For workloads with large numbers of database entries, this is expected
to improve user expererience performance a lot - at the cost of extra
memory usage.
  • Loading branch information
david-cattermole committed Feb 25, 2024
1 parent 9cae621 commit 2f43ec9
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 61 deletions.
2 changes: 1 addition & 1 deletion core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn insert_new_entry_rows_into_database(
//
// Allows filtering the full list of entries by a sub-set of
// times/dates (without having to fetch data from the database).
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Entries {
start_datetime: chrono::DateTime<chrono::Local>,
end_datetime: chrono::DateTime<chrono::Local>,
Expand Down
5 changes: 4 additions & 1 deletion print-gui-bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::main_window::build_ui;
use crate::main_window::GlobalEntries;
use crate::main_window::GlobalEntriesRcRefCell;
use crate::main_window::GlobalState;
use crate::main_window::GlobalStateRcRefCell;
use crate::settings::CommandArguments;
Expand Down Expand Up @@ -41,11 +43,12 @@ fn main() -> Result<()> {

let global_state: GlobalStateRcRefCell =
Rc::new(RefCell::new(GlobalState::new_with_settings(settings)));
let global_entries: GlobalEntriesRcRefCell = Rc::new(RefCell::new(GlobalEntries::new()));

application.connect_activate(clone!(
@strong global_state =>
move |app| {
build_ui(app, global_state.clone())
build_ui(app, global_state.clone(), global_entries.clone())
}
));

Expand Down
Loading

0 comments on commit 2f43ec9

Please sign in to comment.