Skip to content

Commit

Permalink
Rename fn update_all_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
TaQuangKhoi committed Aug 14, 2024
1 parent 13633d4 commit 0d1ad02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ impl eframe::App for TwoDBApp {
}
});
ui.menu_button("Update", |ui| {
self.render_update_self_referencing_tables_button(ui);
self.render_update_tables_button(ui);
self.render_update_self_referencing_tables_button(ui);
self.render_clean_tables_button(ui);
self.render_get_empty_tables_button(ui);
});
Expand Down
7 changes: 4 additions & 3 deletions src/widgets/update_self_referencing_tables_button.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use egui::Ui;
use std::env::var;
use std::thread;
use crate::core::get_tables;
use crate::TwoDBApp;
use crate::working_database::update_all_tables;

impl TwoDBApp {
pub fn render_update_self_referencing_tables_button(&mut self, ui: &mut Ui) {
Expand All @@ -16,12 +16,13 @@ impl TwoDBApp {
fn button_update_self_referencing_tables_event(&mut self) {
thread::spawn(move || {
let database_name_source = var("POSTGRES_DB_SOURCE").unwrap_or(String::from(""));
// get_tables(&database_name_source);
update_all_tables(&database_name_source);

let database_name_target = var("POSTGRES_DB_TARGET").unwrap_or(String::from(""));
// get_tables(&database_name_target);
update_all_tables(&database_name_target);

let text = format!("Done Get Tables for {} and {}", database_name_source, database_name_target);
println!("{}", text);
});
}
}
10 changes: 5 additions & 5 deletions src/working_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ pub fn get_cells(row: &postgres::Row) -> Vec<String> {
cells
}

fn get_all_tables(database_name: String) {
let mut client = connect(database_name).unwrap();
pub fn update_all_tables(database_name: &String) {
let mut client = connect(database_name.clone()).unwrap();
let query =
"SELECT table_name, table_type \
FROM information_schema.tables \
"SELECT table_name, table_type
FROM information_schema.tables
WHERE table_schema = 'public'"
.to_string();

Expand All @@ -127,7 +127,7 @@ fn get_all_tables(database_name: String) {
}
}).filter(|table_name| table_name.len() > 0).collect();

println!("Total base tables: {}", base_tables.len());
println!("Total base tables: {}", base_tables.len().to_string());

for row in rows {
println!("{}", _row_to_string(&row));
Expand Down

0 comments on commit 0d1ad02

Please sign in to comment.