From 93c88ade013ec31cfe7ce0a8fe672dedd8c4c9ac Mon Sep 17 00:00:00 2001 From: Ryan Kegel Date: Wed, 10 Dec 2025 22:21:00 -0500 Subject: [PATCH] moving database files --- db/db.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/db/db.py b/db/db.py index acde135..535ef1e 100644 --- a/db/db.py +++ b/db/db.py @@ -4,7 +4,16 @@ import threading from tinydb import TinyDB DB_ENV = os.environ.get('DB_ENV', 'prod') -base_dir = os.path.dirname(__file__) + + +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +if DB_ENV == 'prod': + base_dir = os.path.join(project_root, 'data/db') +else: + base_dir = os.path.join(project_root, 'test_data/db') + +os.makedirs(base_dir, exist_ok=True) class LockedTable: @@ -66,19 +75,11 @@ class LockedTable: # Setup DB files next to this module -if DB_ENV == 'test': - child_path = os.path.join(base_dir, 'test_children.json') - task_path = os.path.join(base_dir, 'test_tasks.json') - reward_path = os.path.join(base_dir, 'test_rewards.json') - image_path = os.path.join(base_dir, 'test_images.json') - pending_reward_path = os.path.join(base_dir, 'test_pending_rewards.json') - -else: - child_path = os.path.join(base_dir, 'children.json') - task_path = os.path.join(base_dir, 'tasks.json') - reward_path = os.path.join(base_dir, 'rewards.json') - image_path = os.path.join(base_dir, 'images.json') - pending_reward_path = os.path.join(base_dir, 'pending_rewards.json') +child_path = os.path.join(base_dir, 'children.json') +task_path = os.path.join(base_dir, 'tasks.json') +reward_path = os.path.join(base_dir, 'rewards.json') +image_path = os.path.join(base_dir, 'images.json') +pending_reward_path = os.path.join(base_dir, 'pending_rewards.json') # Use separate TinyDB instances/files for each collection _child_db = TinyDB(child_path, indent=2)