Enhance bot functionality and refactor database interactions

- Added `ca-certificates` installation to Dockerfile for improved network security.
- Updated health check command in Dockerfile to include better timeout handling.
- Refactored `run_helper.py` to implement proper signal handling and logging during shutdown.
- Transitioned database operations to an asynchronous model in `async_db.py`, improving performance and responsiveness.
- Updated database schema to support new foreign key relationships and optimized indexing for better query performance.
- Enhanced various bot handlers to utilize async database methods, improving overall efficiency and user experience.
- Removed obsolete database and fix scripts to streamline the project structure.
This commit is contained in:
2025-09-02 18:22:02 +03:00
parent 013892dcb7
commit 1c6a37bc12
59 changed files with 5682 additions and 4204 deletions

26
database/__init__.py Normal file
View File

@@ -0,0 +1,26 @@
"""
Пакет для работы с базой данных.
Содержит:
- models: модели данных
- base: базовый класс для работы с БД
- repositories: репозитории для разных сущностей
- repository_factory: фабрика репозиториев
- async_db: основной класс AsyncBotDB
"""
from .models import (
User, BlacklistUser, UserMessage, TelegramPost, PostContent,
MessageContentLink, Admin, Migration, AudioMessage, AudioListenRecord, AudioModerate
)
from .repository_factory import RepositoryFactory
from .base import DatabaseConnection
from .async_db import AsyncBotDB
# Для обратной совместимости экспортируем старый интерфейс
__all__ = [
'User', 'BlacklistUser', 'UserMessage', 'TelegramPost', 'PostContent',
'MessageContentLink', 'Admin', 'Migration', 'AudioMessage', 'AudioListenRecord', 'AudioModerate',
'RepositoryFactory', 'DatabaseConnection', 'AsyncBotDB'
]