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 0b51672
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions socorro/external/es/supersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
10 changes: 9 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,33 @@ 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 0b51672

Please sign in to comment.