Skip to content

Commit

Permalink
fix: Change databuilder search data extractors to publish name in u…
Browse files Browse the repository at this point in the history
…ser document. (#2274)

* Change databuilder search data extractors to publish `name` in user document.

Signed-off-by: Jackson Goerner <[email protected]>

* Fix unit tests for databuilder.

Signed-off-by: Jackson Goerner <[email protected]>

* Have another shot at fixing the user data tests.

Signed-off-by: Jackson Goerner <[email protected]>

* Bump databuilder patch version.

Signed-off-by: Jackson Goerner <[email protected]>

---------

Signed-off-by: Jackson Goerner <[email protected]>
  • Loading branch information
glipR authored Oct 30, 2024
1 parent 088d30d commit 32b2ab3
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class AtlasSearchDataExtractor(Extractor):
lambda x: AtlasSearchDataExtractorHelpers.get_badges_from_classifications(x), [])
],
'User': [
('name', 'attributes.full_name', None, ''),
('email', 'attributes.qualifiedName', None, ''),
('first_name', 'attributes.first_name', None, ''),
('last_name', 'attributes.last_name', None, ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def _user_search(session: Session, published_tag: str, limit: int) -> List[Dict]

manager_email = user.manager.email if user.manager else ''
user_result = dict(email=user.email,
name=user.full_name,
first_name=user.first_name,
last_name=user.last_name,
full_name=user.full_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Neo4jSearchDataExtractor(Extractor):
where user.full_name is not null
return user.email as email, user.first_name as first_name, user.last_name as last_name,
user.full_name as full_name, user.github_username as github_username, user.team_name as team_name,
user.employee_type as employee_type, manager.email as manager_email,
user.employee_type as employee_type, manager.email as manager_email, user.full_name as name,
user.slack_id as slack_id, user.is_active as is_active, user.role_name as role_name,
REDUCE(sum_r = 0, r in COLLECT(DISTINCT read)| sum_r + r.read_count) AS total_read,
count(distinct b) as total_own,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def _user_search_query(graph: GraphTraversalSource, tag_filter: str) -> List[Dic
'total_own',
'total_follow'
)
traversal = traversal.by('full_name') # name
traversal = traversal.by('email') # email
traversal = traversal.by('first_name') # first_name
traversal = traversal.by('last_name') # last_name
Expand Down
2 changes: 2 additions & 0 deletions databuilder/databuilder/models/user_elasticsearch_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class UserESDocument(ElasticsearchDocument):
"""

def __init__(self,
name: str,
email: str,
first_name: str,
last_name: str,
Expand All @@ -25,6 +26,7 @@ def __init__(self,
total_own: int,
total_follow: int,
) -> None:
self.name = name
self.email = email
self.first_name = first_name
self.last_name = last_name
Expand Down
2 changes: 1 addition & 1 deletion databuilder/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

__version__ = '7.5.1'
__version__ = '7.5.2'

requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'requirements.txt')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def test_user_search(self,
manager = User(rk='test_manager_key', email='[email protected]')
user.manager = manager

expected_dict = dict(email='[email protected]',
expected_dict = dict(name='test_full_name',
email='[email protected]',
first_name='test_first_name',
last_name='test_last_name',
full_name='test_full_name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def test_to_json(self) -> None:
"""
Test string generated from to_json method
"""
test_obj = UserESDocument(email='[email protected]',
test_obj = UserESDocument(name='test_firstname test_lastname',
email='[email protected]',
first_name='test_firstname',
last_name='test_lastname',
full_name='full_name',
Expand All @@ -28,7 +29,8 @@ def test_to_json(self) -> None:
total_own=3,
total_follow=1)

expected_document_dict = {"first_name": "test_firstname",
expected_document_dict = {"name": "test_firstname test_lastname",
"first_name": "test_firstname",
"last_name": "test_lastname",
"full_name": "full_name",
"team_name": "team",
Expand Down

0 comments on commit 32b2ab3

Please sign in to comment.