This commit is contained in:
itqop 2026-02-17 14:13:19 +03:00
parent 987f3e6609
commit 2bd74a5341
3 changed files with 11 additions and 15 deletions

View File

@ -78,6 +78,12 @@ async def check_and_send_reminders(bot: Bot) -> None:
current_run=reminder.next_run_at,
days_interval=reminder.days_interval,
)
next_run = next_run.replace(
hour=reminder.time_of_day.hour,
minute=reminder.time_of_day.minute,
second=0,
microsecond=0,
)
reminder.next_run_at = next_run
reminder.updated_at = time_service.get_now()

View File

@ -244,15 +244,14 @@ async def delete_reminder(session: AsyncSession, reminder_id: int) -> bool:
async def mark_reminder_done(
session: AsyncSession,
reminder_id: int,
next_run_at: datetime,
) -> Optional[Reminder]:
"""
Mark reminder as done and schedule next run.
Mark reminder as done. Does not touch next_run_at the scheduler
already advanced it when the notification was sent.
Args:
session: Database session
reminder_id: Reminder ID
next_run_at: Next execution datetime
Returns:
Updated Reminder instance or None
@ -262,7 +261,6 @@ async def mark_reminder_done(
return None
reminder.last_done_at = _now_local()
reminder.next_run_at = next_run_at
reminder.total_done_count += 1
reminder.updated_at = _now_local()

View File

@ -212,7 +212,8 @@ class RemindersService:
reminder_id: int,
) -> Optional[Reminder]:
"""
Mark reminder as done and schedule next occurrence.
Mark reminder as done. Does not recalculate next_run_at because
the scheduler already advanced it when sending the notification.
Args:
session: Database session
@ -221,16 +222,7 @@ class RemindersService:
Returns:
Updated Reminder instance or None
"""
reminder = await get_reminder_by_id(session, reminder_id)
if not reminder:
return None
next_run_at = self.time_service.calculate_next_occurrence(
current_run=reminder.next_run_at,
days_interval=reminder.days_interval,
)
return await mark_reminder_done(session, reminder_id, next_run_at)
return await mark_reminder_done(session, reminder_id)
async def snooze(
self,