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

@ -99,14 +99,16 @@ class BaserowAPI:
table_data = self.get_all_rows_from_table(table_id.strip())
tables_data[table_id] = table_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."""
reference_map_child = reference_map.copy()
for table_name, table_rows in tables_data.copy().items():
self.process_link_fields(table_name, tables_data, reference_map_child)
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
@ -135,7 +137,7 @@ class BaserowAPI:
self.print_verbose_message(f"Skipped {related_cell_identifier}. Already implemented")
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):

View File

@ -21,7 +21,7 @@ def main():
handle_output(args.quiet, tables_data)
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)
if args.database_id: