Refactor scheduled task repository and schemas for improved type hints and consistency

- Updated type hints from List/Optional to list/None for better readability and consistency across the codebase.
- Refactored import statements for better organization and clarity.
- Enhanced the ScheduledTaskBase schema to use modern type hints.
- Cleaned up unnecessary comments and whitespace in various files.
- Improved error handling and logging in task execution handlers.
- Updated test cases to reflect changes in type hints and ensure compatibility with the new structure.
This commit is contained in:
JSC
2025-08-28 23:38:47 +02:00
parent 96801dc4d6
commit dc89e45675
19 changed files with 292 additions and 291 deletions

View File

@@ -5,15 +5,16 @@ import asyncio
from datetime import datetime
from app.core.database import get_session_factory
from app.models.scheduled_task import RecurrenceType, TaskType
from app.repositories.scheduled_task import ScheduledTaskRepository
from app.models.scheduled_task import TaskType, RecurrenceType
async def create_test_task():
session_factory = get_session_factory()
async with session_factory() as session:
repo = ScheduledTaskRepository(session)
task_data = {
"name": "Live Test Task",
"task_type": TaskType.PLAY_SOUND,
@@ -23,9 +24,9 @@ async def create_test_task():
"user_id": 1,
"recurrence_type": RecurrenceType.NONE,
}
task = await repo.create(task_data)
print(f"Created task: {task.name} (ID: {task.id}) scheduled for {task.scheduled_at}")
if __name__ == "__main__":
asyncio.run(create_test_task())
asyncio.run(create_test_task())