From 2436180e637b22c69a8cf5303a487d94c25a027a Mon Sep 17 00:00:00 2001 From: Quildra Date: Wed, 13 Nov 2024 21:58:40 +0000 Subject: [PATCH] - Marks done, still needs a verfication pass --- database/db_controller.py | 4 ++++ ui/main_window_controller.py | 3 +++ ui/workers/calculate_origin_mark_worker.py | 7 ++++--- ui/workers/gather_evolutions_worker.py | 4 ++-- ui/workers/gather_pokemon_forms_worker.py | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/database/db_controller.py b/database/db_controller.py index 71835a5..c888de0 100644 --- a/database/db_controller.py +++ b/database/db_controller.py @@ -195,6 +195,10 @@ class DBController: self.update_pokemon_field(pfic, "storable_in_home", status) pass + def update_mark(self, pfic, data): + self.update_pokemon_field(pfic, "mark", data) + pass + def update_pokemon_field(self, pfic, field_name, new_value): # Fetch the existing record self.cursor.execute('SELECT data FROM pokemon_forms WHERE PFIC = ?', (pfic,)) diff --git a/ui/main_window_controller.py b/ui/main_window_controller.py index 19be816..12be192 100644 --- a/ui/main_window_controller.py +++ b/ui/main_window_controller.py @@ -91,6 +91,7 @@ class MainWindowController: pass def save_changes(self): + db.save_changes() pass def export_database(self): @@ -159,6 +160,8 @@ class MainWindowController: self.thread_pool.start(worker) def on_marks_calculated(self, data): + for key in data: + db.update_mark(key, data[key]) print("Works Done!") def load_shiftable_forms(self): diff --git a/ui/workers/calculate_origin_mark_worker.py b/ui/workers/calculate_origin_mark_worker.py index e2d70d1..87486de 100644 --- a/ui/workers/calculate_origin_mark_worker.py +++ b/ui/workers/calculate_origin_mark_worker.py @@ -7,7 +7,7 @@ from db import db from utility.functions import get_display_name, get_shiftable_forms class CalculateOriginMarkWorkerSignals(QObject): - finished = pyqtSignal(list) + finished = pyqtSignal(dict) class CalculateOriginMarkWorker(QRunnable): def __init__(self): @@ -149,8 +149,9 @@ class CalculateOriginMarkWorker(QRunnable): else: print(f"Mark for {get_display_name(form_info)} is {mark_id}") self.marks[pfic] = mark_id - continue; - pass + continue + + return self.marks def determine_origin_mark(self, pfic, target_generation): shiftable_forms = get_shiftable_forms(pfic) diff --git a/ui/workers/gather_evolutions_worker.py b/ui/workers/gather_evolutions_worker.py index 0f1da14..803a788 100644 --- a/ui/workers/gather_evolutions_worker.py +++ b/ui/workers/gather_evolutions_worker.py @@ -29,7 +29,7 @@ class GatherEvolutions(QRunnable): except Exception as e: print(f"Error gathering Pokémon home storage status: {e}") - def gather_evolution_data(self, force_refresh = True): + def gather_evolution_data(self, force_refresh = False): all_pokemon_forms = db.get_list_of_pokemon_forms() evolutions = {} @@ -135,7 +135,7 @@ class GatherEvolutions(QRunnable): evolutions[composite_key] = (evolution_info) self.traverse_and_store(next_stage, evolutions, gender) - def parse_evolution_chain(self, table, pokemon_form, force_refresh = True): + def parse_evolution_chain(self, table, pokemon_form, force_refresh = False): cache_record_name = f"evo_{pokemon_form['pfic']}" if force_refresh: cache.purge(cache_record_name) diff --git a/ui/workers/gather_pokemon_forms_worker.py b/ui/workers/gather_pokemon_forms_worker.py index fe2d690..444bf03 100644 --- a/ui/workers/gather_pokemon_forms_worker.py +++ b/ui/workers/gather_pokemon_forms_worker.py @@ -62,7 +62,7 @@ class GatherPokemonFormsWorker(QRunnable): return form_name return "None" - def process_pokemon_entry(self, national_dex_number, pokemon_soup, force_refresh = True): + def process_pokemon_entry(self, national_dex_number, pokemon_soup, force_refresh = False): found_forms = [] generation = get_generation_from_national_dex(national_dex_number) pokemon_name = pokemon_soup.get_text(strip=True)