Update the configuration to use queries and commands.

This commit is contained in:
2025-01-11 17:52:06 +02:00
parent a0846b93a1
commit 70f60ff715
8 changed files with 32 additions and 19 deletions
@@ -1,7 +1,11 @@
from tui_rsync.core.ports.orm import DatabaseManagerPort
from tui_rsync.infrastructure.orm.models import BackupPlanModel, DestinationModel
class RemoveAllBackupBackupPlansCommand:
def __init__(self, database_manager: DatabaseManagerPort):
self.databaseManager = database_manager
def execute(self) -> bool:
rows = BackupPlanModel.delete().execute()
rows = DestinationModel.delete().execute() + rows
@@ -1,8 +1,12 @@
from tui_rsync.core.ports.orm import DatabaseManagerPort
from tui_rsync.infrastructure.orm.dto.dtos import BackupPlanDTO
from tui_rsync.infrastructure.orm.models import BackupPlanModel
class GetAllBackupBackupPlansQuery:
def __init__(self, database_manager: DatabaseManagerPort):
self.databaseManager = database_manager
def execute(self):
return (BackupPlanDTO.to_domain(model) for model in BackupPlanModel.select().iterator())