fix(datasets): fix oversized buttons UI + populate linked_dashboard_count in list endpoint

StatsBar — переделаны огромные карточки-кнопки в компактные пилюли
(rounded-full px-3 py-1 text-sm вместо p-3 grid grid-cols-4).

DatasetList — экшн-кнопки из bg-primary в outline-стиль, карточки
плотнее (p-2.5, py-0.5), ESLint-фиксы (#each key).

Backend — linked_dashboard_count теперь заполняется в списке датасетов
через /dataset/{id}/related_objects (конкурентно, Semaphore=3, timeout=10s).
Ранее поле было только в get_dataset_detail и StatsBar показывал 0.
This commit is contained in:
2026-05-24 09:38:21 +03:00
parent d9669698b8
commit 7219c47357
4 changed files with 94 additions and 32 deletions

View File

@@ -51,6 +51,36 @@ class SupersetDatasetsMixin:
)
return result
# #endregion SupersetClientGetDatasetsSummary
# #region SupersetClientGetDatasetLinkedDashboardCount [TYPE Function] [C:2]
# @PURPOSE: Fetch the number of dashboards linked to a dataset via related_objects endpoint.
# @RELATION: CALLS -> [APIClient]
# @RATIONALE Added to fix linked_count=0 in StatsBar. Reuses the same /dataset/{id}/related_objects call
# that get_dataset_detail() was already making, but as a lightweight count-only call.
# @REJECTED Enriching get_datasets_summary() with more columns rejected — Superset list endpoint
# doesn't include linked_dashboard_count (it's a computed field from related_objects).
def get_dataset_linked_dashboard_count(self, dataset_id: int) -> int:
with belief_scope("get_dataset_linked_dashboard_count", f"id={dataset_id}"):
try:
related_objects = self.network.request(
method="GET", endpoint=f"/dataset/{dataset_id}/related_objects"
)
if isinstance(related_objects, dict):
if "dashboards" in related_objects:
dashboards_data = related_objects["dashboards"]
elif "result" in related_objects and isinstance(
related_objects["result"], dict
):
dashboards_data = related_objects["result"].get("dashboards", [])
else:
dashboards_data = []
return len(dashboards_data)
return 0
except Exception as e:
app_logger.warning(
f"[get_dataset_linked_dashboard_count][Warning] Failed to fetch related dashboards for dataset {dataset_id}: {e}"
)
return 0
# #endregion SupersetClientGetDatasetLinkedDashboardCount
# #region SupersetClientGetDatasetDetail [TYPE Function] [C:3]
# @PURPOSE: Fetches detailed dataset information including columns and linked dashboards.
# @RELATION: CALLS -> [SupersetClientGetDataset]