From c9ac8a03ddd532172a6eecd5dedb6f6e46ae73d3 Mon Sep 17 00:00:00 2001 From: blue-shoes Date: Sun, 26 Nov 2023 12:22:21 -0500 Subject: [PATCH] Method to populate Advanced Calc Options when application is initially deployed --- resources/scripts/adv_calc_setup.sql | 9 +++++++++ ui/main.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 resources/scripts/adv_calc_setup.sql diff --git a/resources/scripts/adv_calc_setup.sql b/resources/scripts/adv_calc_setup.sql new file mode 100644 index 0000000..055e60d --- /dev/null +++ b/resources/scripts/adv_calc_setup.sql @@ -0,0 +1,9 @@ +INSERT INTO adv_calc_option VALUES ('BATTER_G_TARGET', 162); +INSERT INTO adv_calc_option VALUES ('GS_LIMIT', 10); +INSERT INTO adv_calc_option VALUES ('RP_G_TARGET', 10); +INSERT INTO adv_calc_option VALUES ('RP_IP_TARGET', 300); +INSERT INTO adv_calc_option VALUES ('IP_TARGET', 1500); +INSERT INTO adv_calc_option VALUES ('SP_MULTIPLIER', 0.05); +INSERT INTO adv_calc_option VALUES ('RP_MULTIPLIER', 0.15); +INSERT INTO adv_calc_option VALUES ('SP_WITH_ALL_IP', 6); +INSERT INTO adv_calc_option VALUES ('RP_WITH_ALL_IP', 5); \ No newline at end of file diff --git a/ui/main.py b/ui/main.py index fc5b734..a98cb15 100644 --- a/ui/main.py +++ b/ui/main.py @@ -87,6 +87,7 @@ def create_frame(self, frame : tk.Frame): def startup_tasks(self) -> bool: progress_dialog = progress.ProgressDialog(self.container, "Startup Tasks") db_vers = property_service.get_db_version() + sql_dir = self.resource_path('scripts') if db_vers is None: db_vers = Property() db_vers.name = PropertyType.DB_VERSION.value @@ -104,7 +105,6 @@ def startup_tasks(self) -> bool: progress_dialog.set_task_title('Updating Database Structure...') progress_dialog.increment_completion_percent(5) to_run = [] - sql_dir = self.resource_path('scripts') for filename in os.listdir(sql_dir): vers = StrictVersion(filename.split('.sql')[0]) if vers > db_strict_vers and vers <= StrictVersion(v): @@ -131,6 +131,8 @@ def startup_tasks(self) -> bool: progress_dialog.set_task_title("Populating Player Database") salary_services.update_salary_info(pd=progress_dialog) progress_dialog.increment_completion_percent(33) + # We also put values into the advanced calc options table + db_update.run_db_updates([os.path.join(sql_dir, 'adv_calc_setup.sql')]) refresh = salary_services.get_last_refresh() if refresh is None or (datetime.datetime.now() - refresh.last_refresh).days > self.preferences.getint('General', Pref.SALARY_REFRESH_FREQUENCY, fallback=30): progress_dialog.set_task_title("Updating Player Database")