style: isort + black
This commit is contained in:
@@ -2,8 +2,9 @@ from typing import Optional
|
||||
|
||||
from database.repositories.admin_repository import AdminRepository
|
||||
from database.repositories.audio_repository import AudioRepository
|
||||
from database.repositories.blacklist_history_repository import \
|
||||
BlacklistHistoryRepository
|
||||
from database.repositories.blacklist_history_repository import (
|
||||
BlacklistHistoryRepository,
|
||||
)
|
||||
from database.repositories.blacklist_repository import BlacklistRepository
|
||||
from database.repositories.message_repository import MessageRepository
|
||||
from database.repositories.migration_repository import MigrationRepository
|
||||
@@ -13,7 +14,7 @@ from database.repositories.user_repository import UserRepository
|
||||
|
||||
class RepositoryFactory:
|
||||
"""Фабрика для создания репозиториев."""
|
||||
|
||||
|
||||
def __init__(self, db_path: str):
|
||||
self.db_path = db_path
|
||||
self._user_repo: Optional[UserRepository] = None
|
||||
@@ -24,63 +25,63 @@ class RepositoryFactory:
|
||||
self._admin_repo: Optional[AdminRepository] = None
|
||||
self._audio_repo: Optional[AudioRepository] = None
|
||||
self._migration_repo: Optional[MigrationRepository] = None
|
||||
|
||||
|
||||
@property
|
||||
def users(self) -> UserRepository:
|
||||
"""Возвращает репозиторий пользователей."""
|
||||
if self._user_repo is None:
|
||||
self._user_repo = UserRepository(self.db_path)
|
||||
return self._user_repo
|
||||
|
||||
|
||||
@property
|
||||
def blacklist(self) -> BlacklistRepository:
|
||||
"""Возвращает репозиторий черного списка."""
|
||||
if self._blacklist_repo is None:
|
||||
self._blacklist_repo = BlacklistRepository(self.db_path)
|
||||
return self._blacklist_repo
|
||||
|
||||
|
||||
@property
|
||||
def blacklist_history(self) -> BlacklistHistoryRepository:
|
||||
"""Возвращает репозиторий истории банов/разбанов."""
|
||||
if self._blacklist_history_repo is None:
|
||||
self._blacklist_history_repo = BlacklistHistoryRepository(self.db_path)
|
||||
return self._blacklist_history_repo
|
||||
|
||||
|
||||
@property
|
||||
def messages(self) -> MessageRepository:
|
||||
"""Возвращает репозиторий сообщений."""
|
||||
if self._message_repo is None:
|
||||
self._message_repo = MessageRepository(self.db_path)
|
||||
return self._message_repo
|
||||
|
||||
|
||||
@property
|
||||
def posts(self) -> PostRepository:
|
||||
"""Возвращает репозиторий постов."""
|
||||
if self._post_repo is None:
|
||||
self._post_repo = PostRepository(self.db_path)
|
||||
return self._post_repo
|
||||
|
||||
|
||||
@property
|
||||
def admins(self) -> AdminRepository:
|
||||
"""Возвращает репозиторий администраторов."""
|
||||
if self._admin_repo is None:
|
||||
self._admin_repo = AdminRepository(self.db_path)
|
||||
return self._admin_repo
|
||||
|
||||
|
||||
@property
|
||||
def audio(self) -> AudioRepository:
|
||||
"""Возвращает репозиторий аудио."""
|
||||
if self._audio_repo is None:
|
||||
self._audio_repo = AudioRepository(self.db_path)
|
||||
return self._audio_repo
|
||||
|
||||
|
||||
@property
|
||||
def migrations(self) -> MigrationRepository:
|
||||
"""Возвращает репозиторий миграций."""
|
||||
if self._migration_repo is None:
|
||||
self._migration_repo = MigrationRepository(self.db_path)
|
||||
return self._migration_repo
|
||||
|
||||
|
||||
async def create_all_tables(self):
|
||||
"""Создает все таблицы в базе данных."""
|
||||
await self.migrations.create_table() # Сначала создаем таблицу миграций
|
||||
@@ -91,11 +92,11 @@ class RepositoryFactory:
|
||||
await self.posts.create_tables()
|
||||
await self.admins.create_tables()
|
||||
await self.audio.create_tables()
|
||||
|
||||
|
||||
async def check_database_integrity(self):
|
||||
"""Проверяет целостность базы данных."""
|
||||
await self.users.check_database_integrity()
|
||||
|
||||
|
||||
async def cleanup_wal_files(self):
|
||||
"""Очищает WAL файлы."""
|
||||
await self.users.cleanup_wal_files()
|
||||
|
||||
Reference in New Issue
Block a user