Skip to content

Commit 3f87338

Browse files
authored
Merge pull request #63 from ZFordDev/56-integrate-storage-layer-into-scheduler
patched db logic to controller
2 parents b02c81a + b632ca9 commit 3f87338

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

src/startup/controller.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
- Launches the correct UI
1010
- Handles missing dependencies gracefully
1111
12+
NEW (DB-backed):
13+
- Initializes SQLite
14+
- Runs JSON → DB migration if needed
15+
- Injects Repository into Scheduler
16+
1217
This file must not contain UI logic or storage logic.
1318
"""
1419

@@ -49,12 +54,37 @@ def _launch_mode(mode: StartupMode):
4954
"""
5055
Launch the appropriate UI based on the resolved mode.
5156
Lazy imports ensure no heavy UI frameworks load unless needed.
57+
58+
NEW:
59+
- DB initialization
60+
- Migration
61+
- Repository + Scheduler wiring
5262
"""
5363

54-
# Create scheduler lazily (only if a UI is actually launching)
64+
# ---------------------------------------------------------
65+
# NEW: Initialize DB + Repository + Migration
66+
# ---------------------------------------------------------
67+
from storage.db import init_db
68+
from storage.repository import Repository
69+
from storage.migration import needs_migration, run_migration
5570
from logic.scheduler import Scheduler
56-
scheduler = Scheduler()
57-
scheduler.load_tasks()
71+
72+
# 1. Ensure DB + schema exist
73+
init_db()
74+
75+
# 2. Create repository
76+
repo = Repository()
77+
78+
# 3. Run migration if needed
79+
if needs_migration(repo):
80+
run_migration(repo)
81+
82+
# 4. Create DB-backed scheduler
83+
scheduler = Scheduler(repo)
84+
85+
# ---------------------------------------------------------
86+
# OLD UI routing (unchanged)
87+
# ---------------------------------------------------------
5888

5989
if mode == StartupMode.TK:
6090
try:

0 commit comments

Comments
 (0)