mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix(dashboard): 500 error caused by data_for_slices API (#16053)
This commit is contained in:
@@ -1217,10 +1217,10 @@ def get_metric_name(metric: Metric) -> str:
|
||||
|
||||
|
||||
def get_metric_names(metrics: Sequence[Metric]) -> List[str]:
|
||||
return [get_metric_name(metric) for metric in metrics]
|
||||
return [metric for metric in map(get_metric_name, metrics) if metric]
|
||||
|
||||
|
||||
def get_main_metric_name(metrics: Sequence[Metric]) -> Optional[str]:
|
||||
def get_first_metric_name(metrics: Sequence[Metric]) -> Optional[str]:
|
||||
metric_labels = get_metric_names(metrics)
|
||||
return metric_labels[0] if metric_labels else None
|
||||
|
||||
@@ -1427,7 +1427,6 @@ def get_iterable(x: Any) -> List[Any]:
|
||||
:param x: The object
|
||||
:returns: An iterable representation
|
||||
"""
|
||||
|
||||
return x if isinstance(x, list) else [x]
|
||||
|
||||
|
||||
@@ -1464,12 +1463,7 @@ def get_column_names_from_metrics(metrics: List[Metric]) -> List[str]:
|
||||
:param metrics: Ad-hoc metric
|
||||
:return: column name if simple metric, otherwise None
|
||||
"""
|
||||
columns: List[str] = []
|
||||
for metric in metrics:
|
||||
column_name = get_column_name_from_metric(metric)
|
||||
if column_name:
|
||||
columns.append(column_name)
|
||||
return columns
|
||||
return [col for col in map(get_column_name_from_metric, metrics) if col]
|
||||
|
||||
|
||||
def extract_dataframe_dtypes(df: pd.DataFrame) -> List[GenericDataType]:
|
||||
|
||||
Reference in New Issue
Block a user