Skip to content

Commit

Permalink
conditionally enable searching for alert groups via env var (#4287)
Browse files Browse the repository at this point in the history
# What this PR does

re-enables the search for alert groups

## Which issue(s) this PR closes

Closes #2232

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Joey Orlando <[email protected]>
Co-authored-by: Joey Orlando <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 2f1ffcf commit 0acb66b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions engine/apps/api/views/alert_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing

from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Count, Max, Q
from django_filters import rest_framework as filters
Expand Down Expand Up @@ -275,6 +276,11 @@ class AlertGroupView(
pagination_class = AlertGroupCursorPaginator

filter_backends = [SearchFilter, filters.DjangoFilterBackend]
search_fields = (
["=public_primary_key", "=inside_organization_number", "web_title_cache"]
if settings.FEATURE_ALERT_GROUP_SEARCH_ENABLED
else []
)
filterset_class = AlertGroupFilter

def get_serializer_class(self):
Expand Down
1 change: 1 addition & 0 deletions engine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
FEATURE_LABELS_ENABLED_FOR_ALL = getenv_boolean("FEATURE_LABELS_ENABLED_FOR_ALL", default=False)
# Enable labels feature for organizations from the list. Use OnCall organization ID, for this flag
FEATURE_LABELS_ENABLED_PER_ORG = getenv_list("FEATURE_LABELS_ENABLED_PER_ORG", default=list())
FEATURE_ALERT_GROUP_SEARCH_ENABLED = getenv_boolean("FEATURE_ALERT_GROUP_SEARCH_ENABLED", default=False)

TWILIO_API_KEY_SID = os.environ.get("TWILIO_API_KEY_SID")
TWILIO_API_KEY_SECRET = os.environ.get("TWILIO_API_KEY_SECRET")
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/models/alertgroup/alertgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class AlertGroupStore {
params: {
query: {
...incidentFilters,
search,
search: incidentFilters?.search || search,
perpage: this.alertsSearchResult?.page_size,
cursor: this.incidentsCursor,
is_root: true,
Expand Down

0 comments on commit 0acb66b

Please sign in to comment.