Skip to content

Commit

Permalink
add optional list to atlas_search_extractor
Browse files Browse the repository at this point in the history
Signed-off-by: dechoma <dominik.choma@gmail.com>
  • Loading branch information
dechoma committed Jun 1, 2021
1 parent 57ff725 commit 52b706e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions databuilder/databuilder/extractor/atlas_search_data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,33 @@ def _filter_none(input_list: List) -> List:
return list(filter(None, input_list))

@staticmethod
def get_entity_names(entity_list: List) -> List:
def get_entity_names(entity_list: Optional[List]) -> List:
entity_list = entity_list or []
return AtlasSearchDataExtractorHelpers._filter_none(
[e.get('attributes').get('name') for e in entity_list if e.get('status').lower() == 'active'])

@staticmethod
def get_entity_descriptions(entity_list: List) -> List:
def get_entity_descriptions(entity_list: Optional[List]) -> List:
entity_list = entity_list or []
return AtlasSearchDataExtractorHelpers._filter_none(
[e.get('attributes', dict()).get('description') for e in entity_list
if e.get('status').lower() == 'active'])

@staticmethod
def get_badges_from_classifications(classifications: List) -> List:
def get_badges_from_classifications(classifications: Optional[List]) -> List:
classifications = classifications or []
return AtlasSearchDataExtractorHelpers._filter_none(
[c.get('typeName') for c in classifications if c.get('entityStatus', '').lower() == 'active'])

@staticmethod
def get_display_text(meanings: List) -> List:
def get_display_text(meanings: Optional[List]) -> List:
meanings = meanings or []
return AtlasSearchDataExtractorHelpers._filter_none(
[c.get('displayText') for c in meanings if c.get('entityStatus', '').lower() == 'active'])

@staticmethod
def get_last_successful_execution_timestamp(executions: List) -> int:
def get_last_successful_execution_timestamp(executions: Optional[List]) -> int:
executions = executions or []
successful_executions = AtlasSearchDataExtractorHelpers._filter_none(
[e.get('attributes').get('timestamp') for e in executions
if e.get('status', '').lower() == 'active' and e.get('attributes', dict()).get('state') == 'succeeded'])
Expand All @@ -65,7 +70,8 @@ def get_last_successful_execution_timestamp(executions: List) -> int:
return 0

@staticmethod
def get_chart_names(queries: List) -> List[str]:
def get_chart_names(queries: Optional[List]) -> List[str]:
queries = queries or []
charts = []

for query in queries:
Expand Down

0 comments on commit 52b706e

Please sign in to comment.