From 6f865e881a1dc30e27ac04b9366663ac64e9c9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Due=C3=B1as?= Date: Wed, 9 Oct 2024 14:26:24 +0200 Subject: [PATCH] [bugzillarest] Add field with the last comment date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds the field 'last_comment_date' to the enriched indices. Signed-off-by: Santiago Dueñas --- grimoire_elk/enriched/bugzillarest.py | 11 ++++++++++ .../new-reponse-times-on-bugzilla-items.yml | 15 ++++++++++++++ tests/test_bugzillarest.py | 20 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 releases/unreleased/new-reponse-times-on-bugzilla-items.yml diff --git a/grimoire_elk/enriched/bugzillarest.py b/grimoire_elk/enriched/bugzillarest.py index 5859976a5..09f9d62b5 100644 --- a/grimoire_elk/enriched/bugzillarest.py +++ b/grimoire_elk/enriched/bugzillarest.py @@ -136,6 +136,7 @@ def get_rich_item(self, item): # Add extra JSON fields used in Kibana (enriched fields) eitem['comments'] = 0 + eitem['last_comment_date'] = None eitem['number_of_comments'] = 0 eitem['time_to_last_update_days'] = None eitem['time_to_first_attention'] = None @@ -146,8 +147,18 @@ def get_rich_item(self, item): if 'long_desc' in issue: eitem['number_of_comments'] = len(issue['long_desc']) + if 'comments' in issue: eitem['comments'] = len(issue['comments']) + + last_comment_date = None + + if eitem['comments'] > 1: + last_comment_date = str_to_datetime(issue['comments'][-1]['time']) + last_comment_date = last_comment_date.isoformat() + + eitem['last_comment_date'] = last_comment_date + eitem['url'] = item['origin'] + "/show_bug.cgi?id=" + str(issue['id']) eitem['time_to_last_update_days'] = \ get_time_diff_days(eitem['creation_ts'], eitem['delta_ts']) diff --git a/releases/unreleased/new-reponse-times-on-bugzilla-items.yml b/releases/unreleased/new-reponse-times-on-bugzilla-items.yml new file mode 100644 index 000000000..bed756ad8 --- /dev/null +++ b/releases/unreleased/new-reponse-times-on-bugzilla-items.yml @@ -0,0 +1,15 @@ +--- +title: New reponse times on bugzilla items +category: added +author: Santiago Dueñas +issue: null +notes: > + The Bugzilla enriched items include two new + fields to track response times on these type + of repositories. + The field `time_to_first_attention` is the + the time expressed in days between the ticket + creation and the first comment from a contributor + different from the author creating the bug. + The field `last_comment_date` is the date of + the last comment posted in the bug. diff --git a/tests/test_bugzillarest.py b/tests/test_bugzillarest.py index 79f864c4e..a9a3acbbc 100644 --- a/tests/test_bugzillarest.py +++ b/tests/test_bugzillarest.py @@ -103,6 +103,26 @@ def test_time_to_first_attention(self): eitem = enrich_backend.get_rich_item(self.items[index]) self.assertEqual(eitem['time_to_first_attention'], expected[index]) + def test_last_comment_date(self): + """Test whether last_comment_date is added to the enriched item""" + + self._test_raw_to_enrich() + enrich_backend = self.connectors[self.connector][2]() + + expected = [ + "2016-07-27T07:35:45+00:00", + "2016-07-27T10:00:54+00:00", + "2016-07-27T10:02:00+00:00", + "2016-07-27T10:02:14+00:00", + "2016-06-07T00:01:29+00:00", + None, + None + ] + + for index in range(0, len(self.items)): + eitem = enrich_backend.get_rich_item(self.items[index]) + self.assertEqual(eitem['last_comment_date'], expected[index]) + def test_raw_to_enrich_sorting_hat(self): """Test enrich with SortingHat"""