Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/dispatch/incident/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,18 @@ def get_all(*, db_session, project_id: int) -> List[Optional[Incident]]:
return db_session.query(Incident).filter(Incident.project_id == project_id)


def get_all_by_status(
*, db_session, status: str, project_id: int, skip=0, limit=100
) -> List[Optional[Incident]]:
def get_all_by_status(*, db_session, status: str, project_id: int) -> List[Optional[Incident]]:
"""Returns all incidents based on the given status."""
return (
db_session.query(Incident)
.filter(Incident.status == status)
.filter(Incident.project_id == project_id)
.offset(skip)
.limit(limit)
.all()
)


def get_all_last_x_hours_by_status(
*, db_session, status: str, hours: int, project_id: int, skip=0, limit=100
*, db_session, status: str, hours: int, project_id: int
) -> List[Optional[Incident]]:
"""Returns all incidents of a given status in the last x hours."""
now = datetime.utcnow()
Expand All @@ -126,8 +122,6 @@ def get_all_last_x_hours_by_status(
.filter(Incident.status == IncidentStatus.active)
.filter(Incident.created_at >= now - timedelta(hours=hours))
.filter(Incident.project_id == project_id)
.offset(skip)
.limit(limit)
.all()
)

Expand All @@ -137,8 +131,6 @@ def get_all_last_x_hours_by_status(
.filter(Incident.status == IncidentStatus.stable)
.filter(Incident.stable_at >= now - timedelta(hours=hours))
.filter(Incident.project_id == project_id)
.offset(skip)
.limit(limit)
.all()
)

Expand All @@ -148,8 +140,6 @@ def get_all_last_x_hours_by_status(
.filter(Incident.status == IncidentStatus.closed)
.filter(Incident.closed_at >= now - timedelta(hours=hours))
.filter(Incident.project_id == project_id)
.offset(skip)
.limit(limit)
.all()
)

Expand Down