From a484950b6d7193d7620295e25eb00322af020bbb Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 5 Sep 2023 01:20:49 +0200 Subject: [PATCH] In between commit matrix optimization --- matrix_builder.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix_builder.py b/matrix_builder.py index 6d7e82b..01a1f2a 100644 --- a/matrix_builder.py +++ b/matrix_builder.py @@ -11,25 +11,22 @@ class MatrixBuilder: 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) + return tables_data 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() 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.fill_cells_with_related_content(tables_data,table_name, table_rows, reference_map_child) return tables_data - def fill_cells_with_related_content(self, table_name, table_rows, reference_map_child): + def fill_cells_with_related_content(self,tables_data, table_name, table_rows, reference_map_child): """Fill cells with related content.""" for table_row in table_rows: self.print_verbose_message(f"table_row: {table_row}") for table_column_name, table_cell_content in table_row.items(): if table_column_name in reference_map_child: - #Iterriere über Zelleneinträge - #cell_identifier = self.generate_cell_identifier(table_name, table_column_name, table_row) - #self.print_verbose_message(f"cell_identifier: {cell_identifier}") - link_row_table_id = reference_map_child[table_column_name]["link_row_table_id"] self.print_verbose_message(f"link_row_table_id: {link_row_table_id}") @@ -37,6 +34,7 @@ class MatrixBuilder: link_row_related_field_id = reference_map_child[table_column_name]["link_row_related_field_id"] self.print_verbose_message(f"link_row_related_field_id: {link_row_related_field_id}") + new_content=[] for entry_id,entry_content in table_cell_content: related_cell_identifier=self.generate_related_cell_identifier(link_row_table_id,link_row_related_field_id,entry_id) self.print_verbose_message(f"related_cell_identifier: {related_cell_identifier}") @@ -46,6 +44,10 @@ class MatrixBuilder: break reference_map_child[table_column_name]["embeded"].append(related_cell_identifier) + matrix_table = self.build_matrix(tables_data, link_row_table_id, tables_data[link_row_table_id], reference_map_child) + new_content.append(matrix_table) + table_row[table_column_name]=new_content + return tables_data[tables_data] def generate_related_cell_identifier(self, table_id, table_column_id, table_row_id):