Skip to content

Commit

Permalink
Merge branch 'add-keywords-bugzilla' of 'https://github.com/sduenas/g…
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmerchante authored Oct 9, 2024
2 parents eb8984f + cbd6893 commit ef7d581
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 2 deletions.
6 changes: 6 additions & 0 deletions grimoire_elk/enriched/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def get_rich_item(self, item):
if 'votes' in item['data']:
eitem['votes'] = item['data']['votes'][0]['__text__']

# Add keywords
if 'keywords' in item['data'] and '__text__' in item['data']['keywords'][0]:
eitem['keywords'] = item['data']['keywords'][0]['__text__'].split(', ')
else:
eitem['keywords'] = []

if "assigned_to" in issue:
if "name" in issue["assigned_to"][0]:
eitem["assigned"] = issue["assigned_to"][0]["name"]
Expand Down
3 changes: 3 additions & 0 deletions grimoire_elk/enriched/bugzillarest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def get_rich_item(self, item):
eitem["component"] = issue['component']
eitem["product"] = issue['product']

# Keywords
eitem["keywords"] = issue['keywords']

# Fix dates
date_ts = str_to_datetime(issue['creation_time'])
eitem['creation_ts'] = date_ts.strftime('%Y-%m-%dT%H:%M:%S')
Expand Down
8 changes: 8 additions & 0 deletions releases/unreleased/keywords-data-on-enriched-items.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Keywords data on enriched items
category: added
author: Santiago Dueñas <[email protected]>
issue: null
notes: >
Keywords field is included now on the enriched
items of bugzilla and bugzillarest indices.
1 change: 1 addition & 0 deletions schema/bugzilla.csv
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ id,long
is_bugzilla_bug,long
is_bugzillarest_bugrest,long
is_open,boolean
keywords,keyword
labels,list
main_description,keyword
main_description_analyzed,string,false
Expand Down
8 changes: 6 additions & 2 deletions tests/data/bugzilla.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
}
],
"keywords": [
{}
{
"__text__": "robotics"
}
],
"long_desc": [
{
Expand Down Expand Up @@ -416,7 +418,9 @@
}
],
"keywords": [
{}
{
"__text__": "robotics, kernel, analytics"
}
],
"long_desc": [
{
Expand Down
18 changes: 18 additions & 0 deletions tests/test_bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ def test_enrich_repo_labels(self):
eitem = enrich_backend.get_rich_item(item)
self.assertIn(REPO_LABELS, eitem)

def test_enrich_keywords(self):
"""Test whether keywords are included on the enriched items"""

self._test_raw_to_enrich()
enrich_backend = self.connectors[self.connector][2]()

item = self.items[0]
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(eitem['keywords'], ['robotics'])

item = self.items[1]
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(eitem['keywords'], ['robotics', 'kernel', 'analytics'])

for item in self.items[2:]:
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(eitem['keywords'], [])

def test_raw_to_enrich_sorting_hat(self):
"""Test enrich with SortingHat"""

Expand Down
14 changes: 14 additions & 0 deletions tests/test_bugzillarest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ def test_enrich_repo_labels(self):
eitem = enrich_backend.get_rich_item(item)
self.assertIn(REPO_LABELS, eitem)

def test_enrich_keywords(self):
"""Test whether keywords are included on the enriched items"""

self._test_raw_to_enrich()
enrich_backend = self.connectors[self.connector][2]()

for item in self.items[0:5]:
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(eitem['keywords'], [])

item = self.items[6]
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(eitem['keywords'], ['crash', 'regression'])

def test_raw_to_enrich_sorting_hat(self):
"""Test enrich with SortingHat"""

Expand Down

0 comments on commit ef7d581

Please sign in to comment.