11import calendar
22import json
33import logging
4-
54from datetime import date
6- from dateutil .relativedelta import relativedelta
75from typing import List
86
9- from starlette . requests import Request
7+ from dateutil . relativedelta import relativedelta
108from fastapi import APIRouter , BackgroundTasks , Depends , HTTPException , Query , status
11-
129from sqlalchemy .orm import Session
10+ from starlette .requests import Request
1311
12+ from dispatch .auth .models import DispatchUser
1413from dispatch .auth .permissions import (
1514 IncidentEditPermission ,
1615 IncidentJoinOrSubscribePermission ,
1716 IncidentViewPermission ,
1817 PermissionsDependency ,
1918)
20- from dispatch .auth .models import DispatchUser
2119from dispatch .auth .service import get_current_user
2220from dispatch .common .utils .views import create_pydantic_include
2321from dispatch .database .core import get_db
2725from dispatch .models import OrganizationSlug , PrimaryKey
2826from dispatch .participant .models import ParticipantUpdate
2927from dispatch .report import flows as report_flows
30- from dispatch .report .models import TacticalReportCreate , ExecutiveReportCreate
28+ from dispatch .report .models import ExecutiveReportCreate , TacticalReportCreate
3129
3230from .flows import (
3331 incident_add_or_reactivate_participant_flow ,
3735 incident_create_stable_flow ,
3836 incident_update_flow ,
3937)
40- from .metrics import make_forecast , create_incident_metric_query
41- from .models import Incident , IncidentCreate , IncidentPagination , IncidentRead , IncidentUpdate
38+ from .metrics import create_incident_metric_query , make_forecast
39+ from .models import (
40+ Incident ,
41+ IncidentCreate ,
42+ IncidentExpandedPagination ,
43+ IncidentPagination ,
44+ IncidentRead ,
45+ IncidentUpdate ,
46+ )
4247from .service import create , delete , get , update
4348
44-
4549log = logging .getLogger (__name__ )
4650
4751router = APIRouter ()
@@ -63,10 +67,15 @@ def get_incidents(
6367 * ,
6468 common : dict = Depends (common_parameters ),
6569 include : List [str ] = Query ([], alias = "include[]" ),
70+ expand : bool = Query (default = False ),
6671):
6772 """Retrieves a list of incidents."""
73+ print (expand )
6874 pagination = search_filter_sort_paginate (model = "Incident" , ** common )
6975
76+ if expand :
77+ return json .loads (IncidentExpandedPagination (** pagination ).json ())
78+
7079 if include :
7180 # only allow two levels for now
7281 include_sets = create_pydantic_include (include )
0 commit comments