From 776b3d9ac2205b670a6fd630cf829f17519a000d Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 6 Jul 2025 20:16:56 -0400 Subject: [PATCH] Fix active/all token issues --- app/internal/db_wrappers.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/internal/db_wrappers.py b/app/internal/db_wrappers.py index 78ea839..ebc527b 100644 --- a/app/internal/db_wrappers.py +++ b/app/internal/db_wrappers.py @@ -74,7 +74,7 @@ class SystemDbController(): if found_docs: print("Found document (raw dict):", found_docs) converted_systems = [System.from_dict(doc) for doc in found_docs] - print("YURB", found_docs, converted_systems) + print("Found document (converted):", converted_systems) return converted_systems if len(converted_systems) > 0 else None else: print("Document not found.") @@ -83,12 +83,17 @@ class SystemDbController(): print(f"Find failed: {e}") return None - async def find_all_systems(self, query: Dict[str, Any] = {}) -> List[System]: + async def find_all_systems(self, query: Optional[Dict[str, Any]] = None) -> List[System]: print("\n--- Finding multiple documents ---") try: + # Initialize an empty dictionary if no query is provided + if query is None: + query = {} + found_docs = None async with self.db_h as db: # found_docs = await db.find(query) # + if found_docs: print(f"Found {len(found_docs)} documents (raw dicts).") return [System.from_dict(doc) for doc in found_docs] @@ -160,11 +165,9 @@ class DiscordIdDbController(): print(f"Discord ID create failed: {e}") return None - async def find_discord_id(self, query: Dict[str, Any], active_only: bool = False) -> Optional[DiscordId]: + async def find_discord_id(self, query: Dict[str, Any]) -> Optional[DiscordId]: print("\n--- Finding one Discord ID document ---") try: - if active_only: - query["active"] = True found_doc = None async with self.db_h as db: # found_doc = await db.find_one(query) # @@ -178,9 +181,12 @@ class DiscordIdDbController(): print(f"Discord ID find failed: {e}") return None - async def find_discord_ids(self, query: Dict[str, Any] = {}, guild_id: Optional[str] = None, active_only: bool = False) -> Optional[List[DiscordId]]: + async def find_discord_ids(self, query: Optional[Dict[str, Any]] = None, guild_id: Optional[str] = None, active_only: bool = False) -> Optional[List[DiscordId]]: print("\n--- Finding multiple Discord ID documents ---") try: + if query is None: + query = {} + if active_only == True: print("Searching active IDs") query["active"] = True