corvix.domain

Domain models for GitHub notifications.

Attributes

Classes

Notification

Normalized notification from GitHub's notifications API.

NotificationRecord

Scored and rule-evaluated notification persisted for dashboards.

Functions

_as_object_map(→ dict[str, object] | None)

_require_non_empty_str(→ str)

_optional_str(→ str | None)

_optional_bool(→ bool)

_optional_float(→ float)

_optional_str_list(→ list[str])

_optional_context(→ dict[str, object])

parse_timestamp(→ datetime.datetime)

Parse an ISO8601 timestamp into a timezone-aware datetime.

format_timestamp(→ str)

Format a timezone-aware datetime as an ISO8601 string.

notification_key(→ str)

Return a stable account-scoped key for a notification.

_get_non_empty_str_or_default(→ str)

_derive_web_url(→ str | None)

_map_subject_api_url_to_web(→ str | None)

Module Contents

corvix.domain._MIN_API_REPO_SEGMENTS = 4[source][source]
corvix.domain._MIN_RESOURCE_SEGMENTS = 2[source][source]
corvix.domain._RELEASE_TAG_SEGMENTS = 3[source][source]
corvix.domain._ACTIONS_RUNS_SEGMENTS = 3[source][source]
corvix.domain._API_RESOURCE_TO_WEB_PATH[source][source]
corvix.domain._as_object_map(value: object) dict[str, object] | None[source][source]
corvix.domain._require_non_empty_str(payload: collections.abc.Mapping[str, object], key: str, label: str) str[source][source]
corvix.domain._optional_str(payload: collections.abc.Mapping[str, object], key: str) str | None[source][source]
corvix.domain._optional_bool(payload: collections.abc.Mapping[str, object], key: str, default: bool, label: str) bool[source][source]
corvix.domain._optional_float(payload: collections.abc.Mapping[str, object], key: str, default: float, label: str) float[source][source]
corvix.domain._optional_str_list(payload: collections.abc.Mapping[str, object], key: str) list[str][source][source]
corvix.domain._optional_context(payload: collections.abc.Mapping[str, object], key: str) dict[str, object][source][source]
corvix.domain.parse_timestamp(value: str) datetime.datetime[source][source]

Parse an ISO8601 timestamp into a timezone-aware datetime.

corvix.domain.format_timestamp(value: datetime.datetime) str[source][source]

Format a timezone-aware datetime as an ISO8601 string.

class corvix.domain.Notification[source][source]

Normalized notification from GitHub’s notifications API.

thread_id: str[source][source]
repository: str[source][source]
reason: str[source][source]
subject_title: str[source][source]
subject_type: str[source][source]
unread: bool[source][source]
updated_at: datetime.datetime[source][source]
thread_url: str | None = None[source][source]
subject_url: str | None = None[source][source]
web_url: str | None = None[source][source]
account_id: str = 'primary'[source][source]
account_label: str = 'Primary'[source][source]
classmethod from_api_payload(payload: collections.abc.Mapping[str, object], *, account_id: str = 'primary', account_label: str = 'Primary') Notification[source][source]

Build a notification from a GitHub API response payload.

class corvix.domain.NotificationRecord[source][source]

Scored and rule-evaluated notification persisted for dashboards.

notification: Notification[source][source]
score: float[source][source]
excluded: bool[source][source]
matched_rules: list[str] = [][source][source]
actions_taken: list[str] = [][source][source]
dismissed: bool = False[source][source]
context: dict[str, object][source][source]
to_dict() dict[str, object][source][source]

Convert to a JSON-serializable dictionary.

classmethod from_dict(payload: collections.abc.Mapping[str, object]) NotificationRecord[source][source]

Parse a stored record.

corvix.domain.notification_key(notification: Notification) str[source][source]

Return a stable account-scoped key for a notification.

corvix.domain._get_non_empty_str_or_default(payload: collections.abc.Mapping[str, object], key: str, default: str) str[source][source]
corvix.domain._derive_web_url(payload: collections.abc.Mapping[str, object]) str | None[source][source]
corvix.domain._map_subject_api_url_to_web(subject_url: str, repo_name: str, repo_base: str) str | None[source][source]