harden deploy reports and admin alerts
This commit is contained in:
@@ -132,6 +132,22 @@ async def send_admin_telegram_notification(notification: AdminNotification) -> N
|
||||
notification.telegram_status = "sent"
|
||||
|
||||
|
||||
async def retry_admin_telegram_notifications(session: AsyncSession, *, limit: int = 50) -> int:
|
||||
result = await session.execute(
|
||||
select(AdminNotification)
|
||||
.where(AdminNotification.telegram_status.in_(["pending", "failed"]))
|
||||
.order_by(AdminNotification.created_at.asc())
|
||||
.limit(limit)
|
||||
)
|
||||
delivered = 0
|
||||
for notification in result.scalars():
|
||||
await send_admin_telegram_notification(notification)
|
||||
if notification.telegram_status == "sent":
|
||||
delivered += 1
|
||||
await session.commit()
|
||||
return delivered
|
||||
|
||||
|
||||
async def mark_admin_notification_read(
|
||||
session: AsyncSession, notification: AdminNotification
|
||||
) -> AdminNotification:
|
||||
|
||||
Reference in New Issue
Block a user