Skip to content

Commit

Permalink
feat: add attributeFilterConfig to Visualization
Browse files Browse the repository at this point in the history
Added `attributeFilterConfigs` to visualization. This holds the display label information when using a secondary label in a filter.

JIRA: LX-379
risk: low
  • Loading branch information
chrisbonilla95 committed Oct 14, 2024
1 parent 69354eb commit 3cc8bf7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions gooddata-sdk/gooddata_sdk/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,38 @@ def __repr__(self) -> str:
return repr(self._filter)


class VisualizationAttributeFilterConfig:
"""
Represents attribute filter configuration used by a visualization.
"""

def __init__(self, afc: tuple[str, Any]) -> None:
local_id, data = afc
self._local_id = local_id
self._data = data

@property
def local_id(self) -> str:
return self._local_id

@property
def label_id(self) -> str:
return self._data["displayAsLabel"]["identifier"]["id"]

@property
def type(self) -> str:
return self._data["displayAsLabel"]["identifier"]["type"]

def __str__(self) -> str:
return self.__repr__()

def __repr__(self) -> str:
return (
f"VisualizationAttributeFilterConfig(local_id='{self.local_id}', label_id='{self.label_id}', "
f"type='{self.type}')"
)


class VisualizationSortLocator:
def __init__(self, locator: dict[str, str], locator_type: LocatorItemType) -> None:
self._locator = locator
Expand Down Expand Up @@ -546,6 +578,7 @@ def __init__(
side_loads: Optional[SideLoads] = None,
) -> None:
self._vo = from_vis_obj
self._attributeFilterConfigs: Optional[list[VisualizationAttributeFilterConfig]] = None
self._buckets: Optional[list[VisualizationBucket]] = None
self._filters: Optional[list[VisualizationFilter]] = None
self._sorts: Optional[list[VisualizationSort]] = None
Expand All @@ -568,6 +601,15 @@ def are_relations_valid(self) -> str:
# Fallback to true for tests, where fixtures were generated without HTTP header activating this feature
return self._vo["attributes"].get("areRelationsValid", "true")

@property
def attributeFilterConfigs(self) -> list[VisualizationAttributeFilterConfig]:
if self._attributeFilterConfigs is None:
attribute_filter_configs = self._vo["attributes"]["content"]["attributeFilterConfigs"]
self._attributeFilterConfigs = [
VisualizationAttributeFilterConfig(afc) for afc in attribute_filter_configs.items()
]
return self._attributeFilterConfigs

@property
def buckets(self) -> list[VisualizationBucket]:
if self._buckets is None:
Expand Down

0 comments on commit 3cc8bf7

Please sign in to comment.