mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
Update the show all plans command to show if there're no plans.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .get_all_backup_plans_query import GetAllBackupBackupPlansQuery
|
||||
from .get_backup_plan_by_id_query import GetBackupBackupPlanByIdQuery
|
||||
from .get_all_backup_plans_query import GetAllBackupPlansQuery
|
||||
from .get_backup_plan_by_id_query import GetBackupPlanByIdQuery
|
||||
from .get_backup_plan_count_query import GetBackupPlanCountQuery
|
||||
|
||||
__all__ = ['GetAllBackupBackupPlansQuery', 'GetBackupBackupPlanByIdQuery']
|
||||
__all__ = ['GetAllBackupPlansQuery', 'GetBackupPlanByIdQuery', 'GetBackupPlanCountQuery']
|
||||
|
||||
+12
@@ -0,0 +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())
|
||||
+1
-1
@@ -4,7 +4,7 @@ from tui_rsync.infrastructure.orm.dto.dtos import BackupPlanDTO
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
|
||||
|
||||
class GetAllBackupBackupPlansQuery:
|
||||
class GetAllBackupPlansQuery:
|
||||
def __init__(self, database_manager: DatabaseManagerPort):
|
||||
self.databaseManager = database_manager
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ from tui_rsync.infrastructure.orm.dto.dtos import BackupPlanDTO
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
|
||||
|
||||
class GetBackupBackupPlanByIdQuery:
|
||||
class GetBackupPlanByIdQuery:
|
||||
def __init__(self, database_manager: DatabaseManagerPort):
|
||||
self.databaseManager = database_manager
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
from tui_rsync.core.ports.orm import DatabaseManagerPort
|
||||
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
|
||||
|
||||
class GetBackupPlanCountQuery:
|
||||
def __init__(self, database_manager: DatabaseManagerPort):
|
||||
self.databaseManager = database_manager
|
||||
|
||||
def execute(self):
|
||||
return BackupPlanModel.select().count()
|
||||
@@ -1,3 +1,4 @@
|
||||
from .backup_plan_repository_port import BackupPlanRepositoryPort
|
||||
from .backup_plan_repository import BackupPlanRepository
|
||||
|
||||
__all__ = ['BackupPlanRepositoryPort']
|
||||
__all__ = ['BackupPlanRepositoryPort', 'BackupPlanRepository']
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ from tui_rsync.core.shared_kernel.components.common import UUID
|
||||
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
from ..commands import RemoveBackupBackupPlanDestinationsCommand, RemoveBackupBackupPlanCommand
|
||||
from ..queries import GetBackupBackupPlanByIdQuery
|
||||
from ..queries import GetBackupPlanByIdQuery
|
||||
|
||||
|
||||
class BackupPlanRepository(BackupPlanRepositoryPort):
|
||||
@@ -24,7 +24,7 @@ class BackupPlanRepository(BackupPlanRepositoryPort):
|
||||
destination.save(force_insert=True)
|
||||
|
||||
def get_by_id(self, uuid: UUID) -> BackupPlan:
|
||||
query = GetBackupBackupPlanByIdQuery(self.databaseManager)
|
||||
query = GetBackupPlanByIdQuery(self.databaseManager)
|
||||
return query.execute(uuid)
|
||||
|
||||
def update(self, backup_plan: BackupPlan):
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from .backup_plan_service import BackupPlanService
|
||||
from .get_all_backup_plans_service import GetAllBackupPlansService
|
||||
from .get_backup_plan_count_service import GetBackupPlanCountService
|
||||
|
||||
__all__ = ['BackupPlanService', 'GetAllBackupPlansService', 'GetBackupPlanCountService']
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
|
||||
from tui_rsync.core.components.backup_plan.application.queries import GetAllBackupPlansQuery
|
||||
|
||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
||||
|
||||
|
||||
class GetAllBackupPlansService:
|
||||
def __init__(self, get_all_backup_plan_query: GetAllBackupPlansQuery):
|
||||
self.get_all_backup_plan_query = get_all_backup_plan_query
|
||||
|
||||
def get_all(self) -> List[BackupPlan]:
|
||||
return self.get_all_backup_plan_query.execute()
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
from typing import List
|
||||
|
||||
from tui_rsync.core.components.backup_plan.application.queries import GetBackupPlanCountQuery
|
||||
|
||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
||||
|
||||
|
||||
class GetBackupPlanCountService:
|
||||
def __init__(self, get_backup_plan_count_query: GetBackupPlanCountQuery):
|
||||
self.get_backup_plan_count_query = get_backup_plan_count_query
|
||||
|
||||
def count(self) -> int:
|
||||
return self.get_backup_plan_count_query.execute()
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
return self.count() == 0
|
||||
Reference in New Issue
Block a user