mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-15 11:35:47 +02:00
Add birthday task, change migrations to use date instead of datetime
This commit is contained in:
parent
adcf94c66e
commit
8bc0f1fa7a
18 changed files with 249 additions and 49 deletions
0
didier/decorators/__init__.py
Normal file
0
didier/decorators/__init__.py
Normal file
28
didier/decorators/tasks.py
Normal file
28
didier/decorators/tasks.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from didier.cogs.tasks import Tasks
|
||||
|
||||
from database import enums
|
||||
from database.crud.tasks import set_last_task_execution_time
|
||||
|
||||
__all__ = ["timed_task"]
|
||||
|
||||
|
||||
def timed_task(task: enums.TaskType):
|
||||
"""Decorator to log the last execution time of a task"""
|
||||
|
||||
def _decorator(func):
|
||||
@functools.wraps(func)
|
||||
async def _wrapper(tasks_cog: Tasks, *args, **kwargs):
|
||||
await func(tasks_cog, *args, **kwargs)
|
||||
|
||||
async with tasks_cog.client.db_session as session:
|
||||
await set_last_task_execution_time(session, task)
|
||||
|
||||
return _wrapper
|
||||
|
||||
return _decorator
|
||||
Loading…
Add table
Add a link
Reference in a new issue