Skip to content

Commit 8ffbe18

Browse files
Cubewise-RonanMariusWirtz
authored andcommitted
fix(#1062): can not use top paramter on execute_mdx_ui_array
1 parent 980222d commit 8ffbe18

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

TM1py/Services/CellService.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2960,7 +2960,7 @@ def execute_mdx_ui_array(
29602960
sandbox_name=sandbox_name,
29612961
use_compact_json=use_compact_json,
29622962
**kwargs)
2963-
return Utils.build_ui_arrays_from_cellset(raw_cellset_as_dict=data, value_precision=value_precision)
2963+
return Utils.build_ui_arrays_from_cellset(raw_cellset_as_dict=data, value_precision=value_precision, top=top)
29642964

29652965
def execute_view_ui_array(
29662966
self,

TM1py/Utils/Utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def _build_csv_line_items_from_axis_tuple(members: Dict, include_attributes: boo
610610
return line_items
611611

612612

613-
def build_ui_arrays_from_cellset(raw_cellset_as_dict: Dict, value_precision: int):
613+
def build_ui_arrays_from_cellset(raw_cellset_as_dict: Dict, value_precision: int, top: int = None):
614614
""" Transform raw 1,2 or 3-dimension cellset data into concise dictionary
615615
* Useful for grids or charting libraries that want an array of cell values per row
616616
* Returns 3-dimensional cell structure for tabbed grids or multiple charts
@@ -638,6 +638,7 @@ def build_ui_arrays_from_cellset(raw_cellset_as_dict: Dict, value_precision: int
638638
},
639639
:param raw_cellset_as_dict: raw data from TM1
640640
:param value_precision: Integer (optional) specifying number of decimal places to return
641+
:param top: Int, number of cells to return (counting from top)
641642
:return: dict : { titles: [], headers: [axis][], cells: { Page0: { Row0: { [row values], Row1: [], ...}, ...}, ...} }
642643
"""
643644
header_map = build_headers_from_cellset(raw_cellset_as_dict, force_header_dimensionality=3)
@@ -658,6 +659,8 @@ def build_ui_arrays_from_cellset(raw_cellset_as_dict: Dict, value_precision: int
658659
y_header = headers[1][y]['name']
659660
row = []
660661
for x in range(cardinality[0]):
662+
if top and top <= ordinal_cells:
663+
break
661664
raw_value = raw_cellset_as_dict['Cells'][ordinal_cells]['Value'] or 0
662665
if value_precision:
663666
row.append(float(value_format_string.format(raw_value)))

0 commit comments

Comments
 (0)