Skip to content

Commit

Permalink
fix topcrashers
Browse files Browse the repository at this point in the history
  • Loading branch information
relud committed Nov 20, 2024
1 parent fe18969 commit 9988801
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions socorro/external/es/supersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ 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:
# NOTE(relud): If the term is boolean bucket["key"] is 0 or 1,
# and if the term is a string or int bucket["key_as_string"] is
# not populated, so this only catches boolean terms.
term = bucket["key_as_string"]
# Restore es 1.4 format for boolean terms as string
term = term = term[:1].upper()
else:
term = bucket["key"]

Expand Down
8 changes: 7 additions & 1 deletion webapp/crashstats/topcrashers/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -149,6 +148,7 @@ def build_crash_data(**params):
product="Firefox",
version="1.0",
startup_crash=True,
uptime=1,
)
)

Expand All @@ -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,
)
)

Expand All @@ -170,6 +171,7 @@ def build_crash_data(**params):
product="Firefox",
version="3.0",
startup_crash=False,
uptime=500,
)
)

Expand All @@ -179,27 +181,31 @@ 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")
response = client.get(url, {"product": "Firefox", "version": "1.0"})
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")
response = client.get(url, {"product": "Firefox", "version": "2.0"})
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")
response = client.get(url, {"product": "Firefox", "version": "3.0"})
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
Expand Down

0 comments on commit 9988801

Please sign in to comment.