Skip to content

Commit db79718

Browse files
committed
fix(issues): Increase top tag total value with empty keys
In #102049 added the empty tags, but noticing the total values no longer makes sense. Increases the total count when empty values is active
1 parent b962bcc commit db79718

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/sentry/tagstore/snuba/backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,12 @@ def get_group_tag_keys_and_top_values(
749749
]
750750
values_by_key[k] = {vk: vd for vk, vd in sorted_items}
751751

752+
# Increase the count of the key by the count of empty values
753+
for keyobj in keys_with_counts:
754+
stats = empty_stats_map.get(keyobj.key)
755+
if stats and stats.get("count", 0) > 0:
756+
keyobj.count = (keyobj.count or 0) + stats["count"]
757+
752758
for keyobj in keys_with_counts:
753759
key = keyobj.key
754760
values = values_by_key.get(key, dict())

tests/sentry/issues/endpoints/test_group_tags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def test_include_empty_values_for_specific_key_with_feature(self) -> None:
341341
values = {v["value"] for v in response.data[0]["topValues"]}
342342
assert values == {"", "bar"}
343343
assert response.data[0]["topValues"][0]["count"] == 1
344+
assert response.data[0]["totalValues"] == 2
344345

345346
def test_include_empty_values_in_all_tags_with_feature(self) -> None:
346347
event = self.store_event(
@@ -378,6 +379,7 @@ def test_include_empty_values_in_all_tags_with_feature(self) -> None:
378379
foo = next((t for t in response.data if t["key"] == "foo"), None)
379380
assert foo is not None
380381
assert {v["value"] for v in foo["topValues"]} == {"", "bar"}
382+
assert foo["totalValues"] == 2
381383

382384
def test_flags(self) -> None:
383385
event1 = self.store_event(

0 commit comments

Comments
 (0)