Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantinov-Innokentii committed Dec 18, 2024
1 parent 7cfe85e commit f11aa25
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions engine/apps/labels/alert_group_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def assign_labels(
def _apply_dynamic_labels(
alert_receive_channel: "AlertReceiveChannel", raw_request_data: "Alert.RawRequestData"
) -> types.AlertLabels:
from apps.labels.models import LabelKeyCache, LabelValueCache
from apps.labels.models import LabelKeyCache

if alert_receive_channel.alert_group_labels_custom is None:
return {}
Expand All @@ -87,17 +87,9 @@ def _apply_dynamic_labels(
).only("id", "name")
}

# fetch up-to-date label value names
label_value_names = {
v.id: v.name
for v in LabelValueCache.objects.filter(
id__in=[label[1] for label in alert_receive_channel.alert_group_labels_custom if label[1]]
).only("id", "name")
}

result_labels = {}
for label in alert_receive_channel.alert_group_labels_custom:
label = _apply_dynamic_label_entry(label, label_key_names, label_value_names, raw_request_data)
label = _apply_dynamic_label_entry(label, label_key_names, raw_request_data)
if label:
key, value = label
result_labels[key] = value
Expand Down

0 comments on commit f11aa25

Please sign in to comment.