update filtering by started_at
This commit is contained in:
parent
f577073464
commit
1065748008
1 changed files with 1 additions and 7 deletions
|
|
@ -310,12 +310,6 @@ class AlertGroupView(
|
|||
|
||||
return super().get_serializer_class()
|
||||
|
||||
def _add_default_filter_started_at(self, queryset):
|
||||
DEFAULT_STARTED_AT_TIMERANGE_DAYS = 30
|
||||
end_time = timezone.now()
|
||||
start_time = end_time - timedelta(days=DEFAULT_STARTED_AT_TIMERANGE_DAYS)
|
||||
return queryset.filter(started_at__gte=start_time, started_at__lte=end_time)
|
||||
|
||||
def get_queryset(self, ignore_filtering_by_available_teams=False):
|
||||
# no select_related or prefetch_related is used at this point, it will be done on paginate_queryset.
|
||||
|
||||
|
|
@ -340,7 +334,7 @@ class AlertGroupView(
|
|||
|
||||
# This is a quick fix to speed up requests from mobile app by adding default `started_at` filter value
|
||||
if not self.request.query_params.get("started_at"):
|
||||
queryset = self._add_default_filter_started_at(queryset)
|
||||
queryset = queryset.filter(started_at__gte=timezone.now() - timezone.timedelta(days=30))
|
||||
|
||||
if self.action in ("list", "stats") and settings.ALERT_GROUPS_DISABLE_PREFER_ORDERING_INDEX:
|
||||
# workaround related to MySQL "ORDER BY LIMIT Query Optimizer Bug"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue