Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/gooddata_legacy2cloud/dashboards/filter_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# (C) 2026 GoodData Corporation
import logging

from gooddata_legacy2cloud.dashboards.data_classes import DashboardContext
from gooddata_legacy2cloud.helpers import get_cloud_id
from gooddata_legacy2cloud.metrics.attribute_element import AttributeElement
Expand All @@ -8,6 +10,8 @@
FilterContextWrapper,
)

logger = logging.getLogger("migration")

# TODO: refactor FilterContext class to reuse the pydantic mode.
# - [ ] Phase 1: class typed internally, get() dumps before return
# - [ ] Phase 2: get() returns typed object, consumers handle it
Expand Down Expand Up @@ -60,14 +64,25 @@ def _get_filter_elements_by(self, filter: dict) -> list:
new_attr = self.ctx.ldm_mappings.search_mapping_identifier(
obj["attribute"]["meta"]["identifier"]
)
new_attrs.append(
{
"identifier": {
"id": new_attr,
"type": self._transform_attribute_type_value(obj),
# NOTE: This is a workaround for a feature gap. There are Legacy cases of linked filters using references
# to record counts in a dataset. I distinguish them from regular linked filters by length of displayForms
# metadata. This filter setting cannot be migrated to cloud, so we drop it.
if (
len(obj["attribute"].get("content", {}).get("displayForms", []))
== 0
):
logger.warning(
"Attribute display form is empty for `%s`. Skipping.", new_attr
)
else:
new_attrs.append(
{
"identifier": {
"id": new_attr,
"type": self._transform_attribute_type_value(obj),
}
}
}
)
)
if new_attrs:
new_filter_elements.append(
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test_filter_context_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_get_filter_elements_by_wraps_attributes_as_identifier_refs():
ctx.legacy_client.get_object.return_value = {
"attribute": {
"meta": {"identifier": "attr.region.regionid", "category": "attribute"},
"content": {},
"content": {"displayForms": ["mock", "values"]},
}
}
ctx.ldm_mappings.search_mapping_identifier.return_value = "region.regionid"
Expand Down
Loading