fix: revisión inicial respeta horario; health alert solo en horario hábil PYT
This commit is contained in:
10
health.py
10
health.py
@@ -25,6 +25,9 @@ import hashlib
|
||||
import json
|
||||
import secrets
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
_PY_TZ = ZoneInfo("America/Asuncion")
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import aiohttp.web
|
||||
@@ -231,6 +234,13 @@ class HealthServer:
|
||||
await asyncio.sleep(300)
|
||||
if _last_poll_at is None or _alert_sent:
|
||||
continue
|
||||
ahora_py = datetime.now(_PY_TZ)
|
||||
en_horario = (
|
||||
ahora_py.weekday() < 5
|
||||
and self._settings.poll_hora_inicio <= ahora_py.hour < self._settings.poll_hora_fin
|
||||
)
|
||||
if not en_horario:
|
||||
continue
|
||||
delta = datetime.now(timezone.utc) - _last_poll_at
|
||||
if delta <= timedelta(hours=self._settings.health_alert_hours):
|
||||
continue
|
||||
|
||||
11
poller.py
11
poller.py
@@ -205,10 +205,13 @@ class Poller:
|
||||
hora_fin=self._settings.poll_hora_fin,
|
||||
)
|
||||
|
||||
logger.info("revision_inicial_al_arrancar")
|
||||
count = await self.revisar_ahora()
|
||||
if self._on_poll_done:
|
||||
self._on_poll_done(count)
|
||||
if self._en_horario_habitual():
|
||||
logger.info("revision_inicial_al_arrancar")
|
||||
count = await self.revisar_ahora()
|
||||
if self._on_poll_done:
|
||||
self._on_poll_done(count)
|
||||
else:
|
||||
logger.info("revision_inicial_skipped_fuera_de_horario")
|
||||
|
||||
while self._running:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user