Skip to content

Commit

Permalink
[bugzilla] Add keywords field to enriched index
Browse files Browse the repository at this point in the history
This commit adds the 'keywords' field to the enriched
index.

Signed-off-by: Santiago Dueñas <[email protected]>
  • Loading branch information
sduenas committed Oct 8, 2024
1 parent eb8984f commit 1eea904
Show file tree
Hide file tree
Showing 3 changed files with 30 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
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

0 comments on commit 1eea904

Please sign in to comment.