Skip to content

Commit

Permalink
fix: some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wmak committed Aug 27, 2024
1 parent b278ca1 commit 2e303d8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/sentry/api/endpoints/organization_events_trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ def get(self, request: Request, organization) -> Response:
with handle_query_errors():
trend_query = TrendQueryBuilder(
dataset=Dataset.Discover,
params={},
snuba_params=snuba_params,
selected_columns=selected_columns,
config=QueryBuilderConfig(
Expand Down
21 changes: 11 additions & 10 deletions src/sentry/incidents/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from sentry.relay.config.metric_extraction import on_demand_metrics_feature_flags
from sentry.search.events.builder.base import BaseQueryBuilder
from sentry.search.events.fields import is_function, resolve_field
from sentry.search.events.types import SnubaParams
from sentry.seer.anomaly_detection.store_data import send_historical_data_to_seer
from sentry.sentry_apps.services.app import RpcSentryAppInstallation, app_service
from sentry.shared_integrations.exceptions import (
Expand Down Expand Up @@ -348,19 +349,19 @@ def build_incident_query_builder(
) -> BaseQueryBuilder:
snuba_query = incident.alert_rule.snuba_query
start, end = calculate_incident_time_range(incident, start, end, windowed_stats=windowed_stats)
project_ids = list(
IncidentProject.objects.filter(incident=incident).values_list("project_id", flat=True)
projects = Project.objects.filter(
id__in=IncidentProject.objects.filter(incident=incident).values_list("project_id")
)
query_builder = entity_subscription.build_query_builder(
query=snuba_query.query,
project_ids=project_ids,
projects=projects,
environment=snuba_query.environment,
params={
"organization_id": incident.organization_id,
"project_id": project_ids,
"start": start,
"end": end,
},
params=SnubaParams(
organization=incident.organization,
projects=projects,
start=start,
end=end,
),
)
for i, column in enumerate(query_builder.columns):
if column.alias == CRASH_RATE_ALERT_AGGREGATE_ALIAS:
Expand Down Expand Up @@ -426,7 +427,7 @@ def get_incident_aggregates(
snuba_query = incident.alert_rule.snuba_query
entity_subscription = get_entity_subscription_from_snuba_query(
snuba_query,
incident.organization_id,
incident.organization,
)
query_builder = build_incident_query_builder(
incident, entity_subscription, start, end, windowed_stats
Expand Down
15 changes: 8 additions & 7 deletions src/sentry/incidents/serializers/alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
AlertRuleTrigger,
)
from sentry.incidents.utils.types import AlertRuleActivationConditionType
from sentry.search.events.types import SnubaParams
from sentry.snuba.dataset import Dataset
from sentry.snuba.entity_subscription import (
ENTITY_TIME_COLUMNS,
Expand Down Expand Up @@ -347,14 +348,14 @@ def _validate_snql_query(self, data, entity_subscription, projects):
try:
query_builder = entity_subscription.build_query_builder(
query=data["query"],
project_ids=[p.id for p in projects],
projects=projects,
environment=data.get("environment"),
params={
"organization_id": projects[0].organization_id,
"project_id": [p.id for p in projects],
"start": start,
"end": end,
},
params=SnubaParams(
organization=projects[0].organization,
projects=projects,
start=start,
end=end,
),
)
except (InvalidSearchQuery, ValueError) as e:
raise serializers.ValidationError(f"Invalid Query or Metric: {e}")
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/search/snuba/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ def get_basic_event_snuba_condition(
"""
dataset = Dataset.Events if joined_entity.name == ENTITY_EVENTS else Dataset.IssuePlatform
query_builder = UnresolvedQuery(
dataset=dataset, entity=joined_entity, snuba_params=snuba_params, params={}
dataset=dataset, entity=joined_entity, snuba_params=snuba_params
)
return query_builder.convert_search_filter_to_condition(search_filter)

Expand Down
4 changes: 0 additions & 4 deletions src/sentry/snuba/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def query(

builder = ErrorsQueryBuilder(
Dataset.Events,
params={},
snuba_params=snuba_params,
query=query,
selected_columns=selected_columns,
Expand Down Expand Up @@ -110,7 +109,6 @@ def timeseries_query(
equations, columns = categorize_columns(selected_columns)
base_builder = ErrorsTimeseriesQueryBuilder(
Dataset.Events,
params={},
interval=rollup,
snuba_params=snuba_params,
query=query,
Expand Down Expand Up @@ -255,7 +253,6 @@ def top_events_timeseries(

top_events_builder = ErrorsTopEventsQueryBuilder(
Dataset.Events,
params={},
interval=rollup,
top_events=top_events["data"],
other=False,
Expand All @@ -272,7 +269,6 @@ def top_events_timeseries(
if len(top_events["data"]) == limit and include_other:
other_events_builder = ErrorsTopEventsQueryBuilder(
Dataset.Events,
params={},
interval=rollup,
top_events=top_events["data"],
other=True,
Expand Down
3 changes: 0 additions & 3 deletions src/sentry/snuba/issue_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def query(

builder = DiscoverQueryBuilder(
Dataset.IssuePlatform,
{},
snuba_params=snuba_params,
query=query,
selected_columns=selected_columns,
Expand Down Expand Up @@ -149,7 +148,6 @@ def timeseries_query(
equations, columns = categorize_columns(selected_columns)
base_builder = IssuePlatformTimeseriesQueryBuilder(
Dataset.IssuePlatform,
{},
rollup,
snuba_params=snuba_params,
query=query,
Expand All @@ -169,7 +167,6 @@ def timeseries_query(
comp_query_params.end -= comparison_delta
comparison_builder = IssuePlatformTimeseriesQueryBuilder(
Dataset.IssuePlatform,
{},
rollup,
snuba_params=comp_query_params,
query=query,
Expand Down

0 comments on commit 2e303d8

Please sign in to comment.