corvix.notifications.detector

Detect newly-arrived unread notifications by comparing snapshots.

Functions

detect_new_unread_events(...)

Return events for notifications that are new or newly-unread.

Module Contents

corvix.notifications.detector.detect_new_unread_events(previous: list[corvix.domain.NotificationRecord], current: list[corvix.domain.NotificationRecord], min_score: float = 0.0, include_read: bool = False) list[corvix.notifications.models.NotificationEvent][source][source]

Return events for notifications that are new or newly-unread.

A record qualifies when all of the following are true:

  • unread is True in the current snapshot, unless include_read is True in which case read records also qualify.

  • It is not excluded from dashboards and not dismissed.

  • Its score meets min_score.

  • Either it did not exist in the previous snapshot or it existed but was unread=False (read → unread transition, rare but possible).

Parameters

previous:

Records from the snapshot loaded before the current poll cycle.

current:

Records produced by the current poll cycle (post-score/rules).

min_score:

Minimum score for a record to generate an event (default 0 — all unread records qualify).

include_read:

When True, read records also generate events (default False).