Skip to content

Commit

Permalink
Method to populate Advanced Calc Options when application is initiall…
Browse files Browse the repository at this point in the history
…y deployed
  • Loading branch information
blue-shoes committed Nov 26, 2023
1 parent 35965a9 commit c9ac8a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions resources/scripts/adv_calc_setup.sql
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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")
Expand Down

0 comments on commit c9ac8a0

Please sign in to comment.