Skip to content
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
20 changes: 16 additions & 4 deletions src/sentry/seer/explorer/tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import uuid
from datetime import UTC, datetime, timedelta, timezone
from typing import Any, Literal, cast
from typing import Any, cast

from sentry import eventstore, features
from sentry.api import client
Expand Down Expand Up @@ -46,6 +46,7 @@ def execute_table_query(
project_ids: list[int] | None = None,
project_slugs: list[str] | None = None,
sampling_mode: SAMPLING_MODES = "NORMAL",
case_insensitive: bool | None = None,
) -> dict[str, Any] | None:
"""
Execute a query to get table data by calling the events endpoint.
Expand Down Expand Up @@ -84,6 +85,10 @@ def execute_table_query(
"referrer": Referrer.SEER_RPC,
}

# Add boolean params only if provided.
if case_insensitive is not None:
params["caseInsensitive"] = "1" if case_insensitive else "0"

# Remove None values
params = {k: v for k, v in params.items() if v is not None}

Expand All @@ -109,7 +114,8 @@ def execute_timeseries_query(
project_ids: list[int] | None = None,
project_slugs: list[str] | None = None,
sampling_mode: SAMPLING_MODES = "NORMAL",
partial: Literal["0", "1"] | None = None,
partial: bool | None = None,
case_insensitive: bool | None = None,
) -> dict[str, Any] | None:
"""
Execute a query to get chart/timeseries data by calling the events-stats endpoint.
Expand Down Expand Up @@ -143,14 +149,20 @@ def execute_timeseries_query(
"projectSlug": project_slugs,
"sampling": sampling_mode,
"referrer": Referrer.SEER_RPC,
"partial": partial,
"excludeOther": "0", # Always include "Other" series
}

# Add top_events if group_by is provided
if group_by and get_dataset(dataset) in TOP_EVENTS_DATASETS:
params["topEvents"] = 5

# Add boolean params only if provided.
if partial is not None:
params["partial"] = "1" if partial else "0"

if case_insensitive is not None:
params["caseInsensitive"] = "1" if case_insensitive else "0"

# Remove None values
params = {k: v for k, v in params.items() if v is not None}

Expand Down Expand Up @@ -576,7 +588,7 @@ def _get_issue_event_timeseries(
stats_period=stats_period,
interval=interval,
project_ids=[project_id],
partial="1",
partial=True,
)

if data is None:
Expand Down
Loading