diff --git a/aciniformes_backend/worker/scheduler.py b/aciniformes_backend/worker/scheduler.py index 1f97974..b198aca 100644 --- a/aciniformes_backend/worker/scheduler.py +++ b/aciniformes_backend/worker/scheduler.py @@ -70,10 +70,11 @@ async def write_alert(self, alert: AlertCreateSchema): receivers = session.query(Receiver).all() alert = Alert(**alert.model_dump(exclude_none=True)) session.add(alert) - for receiver in receivers: - async with aiohttp.ClientSession() as s: - async with s.request(method=receiver.method, url=receiver.url, data=receiver.receiver_body): - pass + for receiver in receivers: + async with aiohttp.ClientSession() as s: + async with s.request(method=receiver.method, url=receiver.url, data=receiver.receiver_body): + pass + session.commit() @staticmethod def _parse_timedelta(fetcher: Fetcher) -> tuple[int, int]: @@ -148,6 +149,7 @@ def add_metric(self, metric: MetricCreateSchema): with session_factory() as session: metric = Metric(**metric.model_dump(exclude_none=True)) session.add(metric) + session.commit() return metric async def _fetch_it(self, fetcher: Fetcher): diff --git a/requirements.dev.txt b/requirements.dev.txt index 99e3056..e31caad 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -5,6 +5,6 @@ httpx isort pytest pytest_mock -pytest-asyncio +pytest-asyncio==0.21.1 pytest-cov requests