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

Commit f186003

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

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

services/notification/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
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+
store_notification_results,
27+
)
2528
from services.notification.notifiers import (
2629
StatusType,
2730
get_all_notifier_classes_mapping,
@@ -305,8 +308,6 @@ def notify(self, comparison: ComparisonProxy) -> list[IndividualResult]:
305308
for notifier in all_other_notifiers
306309
)
307310

308-
store_notification_results(comparison, results)
309-
310311
return [
311312
IndividualResult(
312313
notifier=notifier.name, title=notifier.title, result=result
@@ -333,6 +334,7 @@ def notify_individual_notifier(
333334
}
334335

335336
log.info("Attempting individual notification", extra=log_extra)
337+
res: NotificationResult | None = None
336338
try:
337339
res = notifier.notify(
338340
comparison, status_or_checks_helper_text=status_or_checks_helper_text
@@ -349,7 +351,14 @@ def notify_individual_notifier(
349351
raise
350352
except Exception:
351353
log.exception("Individual notifier failed", extra=log_extra)
352-
return notifier, None
354+
return notifier, res
355+
finally:
356+
if res is None or res.notification_attempted:
357+
# only running if there is no result (indicating some exception)
358+
# or there was an actual attempt
359+
create_or_update_commit_notification_from_notification_result(
360+
comparison, notifier, res
361+
)
353362

354363

355364
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)