Skip to content

Commit 2463ab8

Browse files
authored
chore(metrics): Remove custom manager for dashboard widgets (#77233)
Removes custom manager for dashboard widgets, since it was added for span based attribute metrics. Signed-off-by: Vjeran Grozdanic <[email protected]>
1 parent 4833129 commit 2463ab8

File tree

2 files changed

+1
-57
lines changed

2 files changed

+1
-57
lines changed

src/sentry/models/dashboard_widget.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from __future__ import annotations
22

33
from enum import Enum
4-
from typing import Any, ClassVar
4+
from typing import Any
55

66
from django.contrib.postgres.fields import ArrayField as DjangoArrayField
77
from django.db import models
8-
from django.db.models import Q
98
from django.utils import timezone
109
from django.utils.translation import gettext_lazy
1110

@@ -19,9 +18,6 @@
1918
sane_repr,
2019
)
2120
from sentry.db.models.fields import JSONField
22-
from sentry.db.models.manager.base import BaseManager
23-
from sentry.db.models.manager.base_query_set import BaseQuerySet
24-
from sentry.models.organization import Organization
2521

2622
ON_DEMAND_ENABLED_KEY = "enabled"
2723

@@ -242,22 +238,6 @@ class Meta:
242238
__repr__ = sane_repr("extraction_state", "spec_hashes")
243239

244240

245-
class DashboardWidgetManager(BaseManager["DashboardWidget"]):
246-
def get_for_metrics(
247-
self, organization: Organization, metric_mris: list[str]
248-
) -> BaseQuerySet[DashboardWidget]:
249-
widget_query_query = Q()
250-
for metric_mri in metric_mris:
251-
widget_query_query |= Q(aggregates__element_contains=metric_mri)
252-
253-
widget_ids = (
254-
DashboardWidgetQuery.objects.filter(widget__dashboard__organization=organization)
255-
.filter(widget_query_query)
256-
.values_list("widget_id", flat=True)
257-
)
258-
return self.filter(id__in=widget_ids)
259-
260-
261241
@region_silo_model
262242
class DashboardWidget(Model):
263243
"""
@@ -285,7 +265,6 @@ class DashboardWidget(Model):
285265
dataset_source = BoundedPositiveIntegerField(
286266
choices=DatasetSourcesTypes.as_choices(), default=DatasetSourcesTypes.UNKNOWN.value
287267
)
288-
objects: ClassVar[DashboardWidgetManager] = DashboardWidgetManager()
289268

290269
class Meta:
291270
app_label = "sentry"

tests/sentry/models/test_dashboard_widget.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)