mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 18:35:28 +03:00
Initial commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
from datetime import datetime
|
||||
|
||||
from dishka import AsyncContainer
|
||||
|
||||
from trudex.infrastructure.database.dao.test import TestDAO
|
||||
from trudex.infrastructure.database.models import Test
|
||||
|
||||
|
||||
async def deactivate_expired_tests(container: AsyncContainer):
|
||||
async with container() as request_container:
|
||||
test_dao = await request_container.get(TestDAO)
|
||||
|
||||
tests = await test_dao.get_all()
|
||||
|
||||
for test in tests:
|
||||
if test.expires_at and test.expires_at < datetime.utcnow() and test.is_active:
|
||||
await test_dao.update(test.id, is_active=False)
|
||||
Reference in New Issue
Block a user