Skip to content

Commit

Permalink
If filter spec is string, load to dict (#5503)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Nov 19, 2024
1 parent 4bc324c commit 2fb62a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dispatch/incident/metrics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import math
from calendar import monthrange
Expand Down Expand Up @@ -31,12 +32,14 @@ def create_incident_metric_query(
db_session,
end_date: date,
start_date: date = None,
filter_spec: List[dict] = None,
filter_spec: List[dict] | str | None = None,
):
"""Fetches eligible incidents."""
query = db_session.query(Incident)

if filter_spec:
if isinstance(filter_spec, str):
filter_spec = json.loads(filter_spec)
query = apply_filter_specific_joins(Incident, filter_spec, query)
query = apply_filters(query, filter_spec)

Expand Down

0 comments on commit 2fb62a3

Please sign in to comment.