Skip to content

Commit

Permalink
[bugzilla] 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 db24410 commit ed0aaf0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions grimoire_elk/enriched/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,21 @@ def get_rich_item(self, item):

# Add extra JSON fields used in Kibana (enriched fields)
eitem['comments'] = 0
eitem['last_comment_date'] = None
eitem['url'] = None

if 'long_desc' in issue:
eitem['comments'] = len(issue['long_desc'])

last_comment_date = None

if eitem['comments'] > 1:
last_comment = issue['long_desc'][-1]
last_comment_date = str_to_datetime(last_comment['bug_when'][0]['__text__'])
last_comment_date = last_comment_date.isoformat()

eitem['last_comment_date'] = last_comment_date

eitem['url'] = item['origin'] + "/show_bug.cgi?id=" + issue['bug_id'][0]['__text__']
eitem['resolution_days'] = \
get_time_diff_days(eitem['creation_date'], eitem['delta_ts'])
Expand Down
1 change: 1 addition & 0 deletions schema/bugzilla.csv
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ is_bugzillarest_bugrest,long
is_open,boolean
keywords,keyword
labels,list
last_comment_date,date
main_description,keyword
main_description_analyzed,string,false
metadata__enriched_on,date
Expand Down
21 changes: 21 additions & 0 deletions tests/test_bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Alvaro del Castillo <[email protected]>
# Valerio Cosentino <[email protected]>
#

import logging
import unittest

Expand Down Expand Up @@ -105,6 +106,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 = [
"2013-06-25T11:55:46+02:00",
"2013-06-25T11:55:46+02:00",
None,
"2013-06-25T11:55:46+02:00",
"2013-06-25T11:55:46+02:00",
None,
"2014-08-01T11:55:46+02:00"
]

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 ed0aaf0

Please sign in to comment.