From 0e51573d1dd37acb44f5dc378301ad4a0602e7d9 Mon Sep 17 00:00:00 2001 From: Daniel Thorn Date: Wed, 20 Nov 2024 15:06:56 -0800 Subject: [PATCH] fix topcrashers --- socorro/external/es/supersearch.py | 8 ++++---- webapp/crashstats/topcrashers/tests/test_views.py | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/socorro/external/es/supersearch.py b/socorro/external/es/supersearch.py index 1f3edfbccd..dc213ada38 100644 --- a/socorro/external/es/supersearch.py +++ b/socorro/external/es/supersearch.py @@ -142,11 +142,11 @@ def _format(aggregation): return aggregation for i, bucket in enumerate(aggregation["buckets"]): - if isinstance(bucket["key"], bool): - # Restore es 1.4 format for boolean terms as string - term = "T" if bucket["key"] else "F" - elif "key_as_string" in bucket: + if "key_as_string" in bucket: term = bucket["key_as_string"] + if term in ("true", "false") and bucket["key"] in (1, 0): + # Restore es 1.4 format for boolean terms as string + term = term = term[:1].upper() else: term = bucket["key"] diff --git a/webapp/crashstats/topcrashers/tests/test_views.py b/webapp/crashstats/topcrashers/tests/test_views.py index ea37e7c940..20cee20ae5 100644 --- a/webapp/crashstats/topcrashers/tests/test_views.py +++ b/webapp/crashstats/topcrashers/tests/test_views.py @@ -135,7 +135,6 @@ def build_crash_data(**params): "os_name": "Linux", "process_type": "parent", "report_type": "crash", - "uptime": 500, } data.update(params) return data @@ -149,6 +148,7 @@ def build_crash_data(**params): product="Firefox", version="1.0", startup_crash=True, + uptime=1, ) ) @@ -160,6 +160,7 @@ def build_crash_data(**params): product="Firefox", version="2.0", startup_crash=startup_crash, + uptime=1 if startup_crash else 500, ) ) @@ -170,6 +171,7 @@ def build_crash_data(**params): product="Firefox", version="3.0", startup_crash=False, + uptime=500, ) ) @@ -179,6 +181,7 @@ def build_crash_data(**params): startup_crash_msg = 'title="Startup Crash"' potential_startup_crash_msg = 'title="Potential Startup Crash"' + potential_startup_window_crash_msg = 'title="Potential Startup Crash, more than ' # Request Firefox 1.0 where crash data is startup_crash=True url = reverse("topcrashers:topcrashers") @@ -186,6 +189,7 @@ def build_crash_data(**params): assert response.status_code == 200 assert startup_crash_msg in smart_str(response.content) assert potential_startup_crash_msg not in smart_str(response.content) + assert potential_startup_window_crash_msg in smart_str(response.content) # Request Firefox 2.0 where most crash data is startup_crash=True url = reverse("topcrashers:topcrashers") @@ -193,6 +197,7 @@ def build_crash_data(**params): assert response.status_code == 200 assert startup_crash_msg not in smart_str(response.content) assert potential_startup_crash_msg in smart_str(response.content) + assert potential_startup_window_crash_msg in smart_str(response.content) # Request Firefox 3.0 where crash data is startup_crash=False url = reverse("topcrashers:topcrashers") @@ -200,6 +205,7 @@ def build_crash_data(**params): assert response.status_code == 200 assert startup_crash_msg not in smart_str(response.content) assert potential_startup_crash_msg not in smart_str(response.content) + assert potential_startup_window_crash_msg not in smart_str(response.content) def test_product_sans_featured_version(self, client, db, preferred_es_helper): # Index a bunch of version=1.0 data so we have an active version