Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit f3d63d1

Browse files
committed
revert changes to batch CommitNotification updates
1 parent 94a0697 commit f3d63d1

2 files changed

Lines changed: 12 additions & 21 deletions

File tree

services/notification/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
from services.comparison import ComparisonProxy
2222
from services.decoration import Decoration
2323
from services.license import is_properly_licensed
24-
from services.notification.commit_notifications import store_notification_results
24+
from services.notification.commit_notifications import (
25+
create_or_update_commit_notification_from_notification_result,
26+
)
2527
from services.notification.notifiers import (
2628
StatusType,
2729
get_all_notifier_classes_mapping,
@@ -305,8 +307,6 @@ def notify(self, comparison: ComparisonProxy) -> list[IndividualResult]:
305307
for notifier in all_other_notifiers
306308
)
307309

308-
store_notification_results(comparison, results)
309-
310310
return [
311311
IndividualResult(
312312
notifier=notifier.name, title=notifier.title, result=result
@@ -333,6 +333,7 @@ def notify_individual_notifier(
333333
}
334334

335335
log.info("Attempting individual notification", extra=log_extra)
336+
res: NotificationResult | None = None
336337
try:
337338
res = notifier.notify(
338339
comparison, status_or_checks_helper_text=status_or_checks_helper_text
@@ -349,7 +350,14 @@ def notify_individual_notifier(
349350
raise
350351
except Exception:
351352
log.exception("Individual notifier failed", extra=log_extra)
352-
return notifier, None
353+
return notifier, res
354+
finally:
355+
if res is None or res.notification_attempted:
356+
# only running if there is no result (indicating some exception)
357+
# or there was an actual attempt
358+
create_or_update_commit_notification_from_notification_result(
359+
comparison, notifier, res
360+
)
353361

354362

355363
def split_notifiers(

services/notification/commit_notifications.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
import sentry_sdk
43
from sqlalchemy.orm.session import Session
54

65
from database.enums import NotificationState
@@ -14,22 +13,6 @@
1413
log = logging.getLogger(__name__)
1514

1615

17-
@sentry_sdk.trace
18-
def store_notification_results(
19-
comparison: ComparisonProxy,
20-
results: list[tuple[AbstractBaseNotifier, NotificationResult | None]],
21-
):
22-
# TODO: we should change this to a batch "INSERT ON CONFLICT UPDATE" eventually,
23-
# as this currently results in quite some inefficient query patterns.
24-
for notifier, result in results:
25-
if result is None or result.notification_attempted:
26-
# only running if there is no result (indicating some exception)
27-
# or there was an actual attempt
28-
create_or_update_commit_notification_from_notification_result(
29-
comparison, notifier, result
30-
)
31-
32-
3316
def create_or_update_commit_notification_from_notification_result(
3417
comparison: ComparisonProxy,
3518
notifier: AbstractBaseNotifier,

0 commit comments

Comments
 (0)