Implemented multi table matrix

This commit is contained in:
Kevin Veen-Birkenbach 2023-09-05 00:33:58 +02:00
parent ad96811e0b
commit 63525c22fa
2 changed files with 10 additions and 8 deletions

View File

@ -100,13 +100,15 @@ class BaserowAPI:
tables_data[table_id] = table_data tables_data[table_id] = table_data
return tables_data return tables_data
def build_matrix(self, tables_data, reference_map={}): def build_multitable_matrix(self, tables_data):
for table_name, table_rows in tables_data.copy().items():
self.build_matrix(tables_data,table_name, table_rows)
def build_matrix(self, tables_data, table_name, table_rows, reference_map={}):
"""Build a matrix with linked rows filled recursively.""" """Build a matrix with linked rows filled recursively."""
reference_map_child = reference_map.copy() reference_map_child = reference_map.copy()
self.process_link_fields(table_name, tables_data, reference_map_child)
for table_name, table_rows in tables_data.copy().items(): self.fill_cells_with_related_content(table_name, table_rows, reference_map_child)
self.process_link_fields(table_name, tables_data, reference_map_child)
self.fill_cells_with_related_content(table_name, table_rows, reference_map_child)
return tables_data return tables_data
@ -135,7 +137,7 @@ class BaserowAPI:
self.print_verbose_message(f"Skipped {related_cell_identifier}. Already implemented") self.print_verbose_message(f"Skipped {related_cell_identifier}. Already implemented")
break break
reference_map_child[table_column_name]["embeded"].add(related_cell_identifier) reference_map_child[table_column_name]["embeded"].append(related_cell_identifier)
def generate_related_cell_identifier(self, table_id, table_column_id, table_row_id): def generate_related_cell_identifier(self, table_id, table_column_id, table_row_id):

View File

@ -21,7 +21,7 @@ def main():
handle_output(args.quiet, tables_data) handle_output(args.quiet, tables_data)
if "matrix" in args.output: if "matrix" in args.output:
matrix_data = api.build_matrix(tables_data) matrix_data = api.build_multitable_matrix(tables_data)
handle_output(args.quiet, matrix_data) handle_output(args.quiet, matrix_data)
if args.database_id: if args.database_id: