fixes
This commit is contained in:
parent
987f3e6609
commit
2bd74a5341
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue