Permalink
Browse files

bug 977917 - totalNumberOfCrashes returned by tcbs is wrong

  • Loading branch information...
rhelmer committed Feb 28, 2014
1 parent c9dc376 commit 59be021535b0123528681e582cf301a39b67e099
Showing with 55 additions and 5 deletions.
  1. +6 −3 socorro/external/postgresql/tcbs.py
  2. +49 −2 socorro/unittest/external/postgresql/test_tcbs.py
@@ -116,7 +116,8 @@ def getListOfTopCrashersBySignature(connection, dbParams):
version_list,
%s / total_crashes::float as percent_of_total,
startup_count / %s::float as startup_percent,
- is_gc_count
+ is_gc_count,
+ total_crashes::int
FROM tcbs_window
ORDER BY %s DESC
LIMIT %s
@@ -202,7 +203,7 @@ def listOfListsWithChangeInRank(listOfQueryResultsIterable):
'plugin_count', 'content_count',
'first_report_exact', 'versions',
'percentOfTotal', 'startup_percent',
- 'is_gc_count'], aRow))
+ 'is_gc_count', 'total_crashes'], aRow))
aRowAsDict['currentRank'] = rank
aRowAsDict['first_report'] = (
aRowAsDict['first_report_exact'].strftime('%Y-%m-%d'))
@@ -293,7 +294,9 @@ def twoPeriodTopCrasherComparison(
#context['logger'].debug('listOfTopCrashers %s' % listOfTopCrashers)
totalNumberOfCrashes = totalPercentOfTotal = 0
for x in listOfTopCrashers:
- totalNumberOfCrashes += x.get('count', 0)
+ if 'total_crashes' in x:
+ totalNumberOfCrashes = x['total_crashes']
+ del x['total_crashes']
totalPercentOfTotal += x.get('percentOfTotal', 0)
result = {
@@ -247,7 +247,8 @@ def test_listOfListsWithChangeInRank(self):
'signature': 'Fake Signature #1',
'versions_count': 2,
'previousPercentOfTotal': 0.58333333333333304,
- 'plugin_count': 0
+ 'plugin_count': 0,
+ 'total_crashes': 8
}, {
'count': 3L,
'mac_count': 1L,
@@ -268,7 +269,8 @@ def test_listOfListsWithChangeInRank(self):
'signature': 'Fake Signature #2',
'versions_count': 6,
'previousPercentOfTotal': 0.41666666666666702,
- 'plugin_count': 0
+ 'plugin_count': 0,
+ 'total_crashes': 8
}]]
self.assertEqual(res, res_expected)
@@ -355,3 +357,48 @@ def test_twoPeriodTopCrasherComparison(self):
}
self.assertEqual(res, res_expected)
+
+ #--------------------------------------------------------------------------
+ def test_twoPeriodTopCrasherComparisonLimited(self):
+
+ lastweek = self.now - datetime.timedelta(days=7)
+ lastweek_str = datetimeutil.date_to_string(lastweek.date())
+ two_weeks = datetimeutil.date_to_string(self.now.date() -
+ datetime.timedelta(days=14))
+
+ self.params.limit = 1
+ res = tcbs.twoPeriodTopCrasherComparison(
+ self.connection,
+ self.params
+ )
+
+ res_expected = {
+ 'totalPercentage': 0.58333333333333304,
+ 'end_date': lastweek_str,
+ 'start_date': two_weeks,
+ 'crashes': [{
+ 'count': 14L,
+ 'mac_count': 1L,
+ 'content_count': 0,
+ 'first_report': lastweek_str,
+ 'previousRank': 'null',
+ 'currentRank': 0,
+ 'startup_percent': None,
+ 'versions': 'plugin1, plugin2',
+ 'first_report_exact': lastweek_str + ' 00:00:00',
+ 'percentOfTotal': 0.58333333333333304,
+ 'changeInRank': 'new',
+ 'is_gc_count': 1L,
+ 'win_count': 12L,
+ 'changeInPercentOfTotal': 'new',
+ 'linux_count': 1L,
+ 'hang_count': 0L,
+ 'signature': 'Fake Signature #1',
+ 'versions_count': 2,
+ 'previousPercentOfTotal': 'null',
+ 'plugin_count': 0
+ }],
+ 'totalNumberOfCrashes': 24L
+ }
+
+ self.assertEqual(res, res_expected)

0 comments on commit 59be021

Please sign in to comment.