Skip to content

Commit

Permalink
[bugzillarest] Add field with the last comment date
Browse files Browse the repository at this point in the history
This commit adds the field 'last_comment_date' to
the enriched indices.

Signed-off-by: Santiago Dueñas <[email protected]>
  • Loading branch information
sduenas committed Oct 10, 2024
1 parent ed0aaf0 commit 6f865e8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions grimoire_elk/enriched/bugzillarest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])
Expand Down
15 changes: 15 additions & 0 deletions releases/unreleased/new-reponse-times-on-bugzilla-items.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: New reponse times on bugzilla items
category: added
author: Santiago Dueñas <[email protected]>
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.
20 changes: 20 additions & 0 deletions tests/test_bugzillarest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down

0 comments on commit 6f865e8

Please sign in to comment.