Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditionally enable searching for alert groups via env var #4287

Merged
merged 12 commits into from
Jun 4, 2024
6 changes: 6 additions & 0 deletions engine/apps/api/views/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
)
from common.api_helpers.mixins import PreviewTemplateMixin, PublicPrimaryKeyMixin, TeamFilteringMixin
from common.api_helpers.paginators import AlertGroupCursorPaginator
from django.conf import settings


def get_integration_queryset(request):
Expand Down Expand Up @@ -277,6 +278,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
17 changes: 10 additions & 7 deletions grafana-plugin/src/models/alertgroup/alertgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,20 @@ export class AlertGroupStore {
);
const timestamp = new Date().getTime();
this.latestFetchAlertGroupsTimestamp = timestamp;
const query = {
...this.incidentFilters,
perpage: this.alertsSearchResult?.page_size,
cursor: this.incidentsCursor,
is_root: true
};
if (this.incidentFilters && !this.incidentFilters.search) {
sreway marked this conversation as resolved.
Show resolved Hide resolved
query.search = search;
}
const {
data: { results, next: nextRaw, previous: previousRaw, page_size },
} = await onCallApi().GET('/alertgroups/', {
params: {
query: {
...this.incidentFilters,
search,
perpage: this.alertsSearchResult?.page_size,
cursor: this.incidentsCursor,
is_root: true,
},
query: query,
sreway marked this conversation as resolved.
Show resolved Hide resolved
},
});

Expand Down