When creating new ticket make sure we pick report with highest count so we don't end up linking to unrelated report if clustering splits the problem.
Closes #172.
Signed-off-by: Richard Marko rmarko@redhat.com --- pyfaf/bugzilla.py | 2 +- pyfaf/storage/problem.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/pyfaf/bugzilla.py b/pyfaf/bugzilla.py index f135655..a8db6ec 100644 --- a/pyfaf/bugzilla.py +++ b/pyfaf/bugzilla.py @@ -713,7 +713,7 @@ class Bugzilla(object): # pick first and assign this bug to it data['component'] = components.pop()
- report = problem.reports[0] + report = problem.sorted_reports[0] if not report.backtraces: logging.warning('Refusing to process report with no backtrace.') continue diff --git a/pyfaf/storage/problem.py b/pyfaf/storage/problem.py index 7242517..e8ee1a5 100644 --- a/pyfaf/storage/problem.py +++ b/pyfaf/storage/problem.py @@ -92,3 +92,11 @@ class Problem(GenericTable): sorted by quality. ''' return sorted(self.backtraces, key=lambda bt: bt.quality, reverse=True) + + @property + def sorted_reports(self): + """ + Return list of all reports sorted by report count. + """ + + return sorted(self.reports, key=lambda report: report.count, reverse=True)
It's better to use hashes instead of IDs which might change, we have support for this since 3000b1b.
Closes #170.
Signed-off-by: Richard Marko rmarko@redhat.com --- config/templates/bugzilla_new_body | 2 +- config/templates/bugzilla_update_comment | 2 +- pyfaf/bugzilla.py | 16 +++++++++++++++- tests/bugzilla | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/config/templates/bugzilla_new_body b/config/templates/bugzilla_new_body index d6402eb..a4b01f5 100644 --- a/config/templates/bugzilla_new_body +++ b/config/templates/bugzilla_new_body @@ -3,7 +3,7 @@ Description of problem: Faf server recevied number of crash reports for this package.
Problem URL: -{{ server_url }}{% url pyfaf.hub.problems.views.item problem.id %} +{{ server_url }}{% url pyfaf.hub.problems.views.bthash_forward faf_hash %}
Version-Release number of selected component: {{ package.nvra }} diff --git a/config/templates/bugzilla_update_comment b/config/templates/bugzilla_update_comment index 6a1cc6a..c86b2af 100644 --- a/config/templates/bugzilla_update_comment +++ b/config/templates/bugzilla_update_comment @@ -2,6 +2,6 @@ This problem received over {{report_count}} reports. {% if server_url %} Following link might provide more details: -{{ server_url }}{% url pyfaf.hub.problems.views.item problem.id %} +{{ server_url }}{% url pyfaf.hub.problems.views.bthash_forward faf_hash %} {% endif %} {% endautoescape %} diff --git a/pyfaf/bugzilla.py b/pyfaf/bugzilla.py index a8db6ec..1647f66 100644 --- a/pyfaf/bugzilla.py +++ b/pyfaf/bugzilla.py @@ -735,6 +735,7 @@ class Bugzilla(object): data['executable'] = report.executables[0].path
data['duphash'] = report.backtraces[0].hash + data['faf_hash'] = report.backtraces[0].hash
highest_version = -1 highest_release = None @@ -893,9 +894,22 @@ class Bugzilla(object): new_wb = '{0} reports:{1}'.format(bug.whiteboard, current_count)
+ # get top report + if not problem.reports: + logging.warning('Refusing to process problem with no reports.') + continue + + report = problem.sorted_reports[0] + if not report.backtraces: + logging.warning('Refusing to process report with no backtrace.') + continue + + faf_hash = report.backtraces[0].hash + comment = template.render(template_name, dict(report_count=current_count, - problem=problem)) + problem=problem, + faf_hash=faf_hash))
logging.info('Adding comment to bug #{0}.' ' Comment:\n\n{1}\n'.format(bug.id, comment)) diff --git a/tests/bugzilla b/tests/bugzilla index 8cc1fe2..fd6b1fe 100755 --- a/tests/bugzilla +++ b/tests/bugzilla @@ -291,7 +291,7 @@ class BugzillaTestCase(faftests.RealworldCase): self.assertIn('in unknown function', bug['summary'])
self.assertIn('reports count', bug['description']) - self.assertIn('https://example.org/problems/1/', bug['description']) + self.assertIn('https://example.org/problems/bthash/', bug['description']) self.assertIn('server@example.org', bug['description'])
self.assertNotIn('None', bug['summary']) @@ -390,7 +390,7 @@ class BugzillaTestCase(faftests.RealworldCase): break
text = comment.get_lob('content') - self.assertIn('https://example.org/problems/1/', text) + self.assertIn('https://example.org/problems/bthash/', text) self.assertIn(str(prob.reports_count), text)
def test_update_bugs_doesnt_update_too_soon(self):
crash-catcher@lists.fedorahosted.org