From 085e7962fa188296a85e242a100966b89ece5ed5 Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Mon, 23 Oct 2023 18:10:52 +0200 Subject: [PATCH] Looking into type performance with Bernhard --- openatlas/__init__.py | 9 +++++++++ openatlas/models/type.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openatlas/__init__.py b/openatlas/__init__.py index 80a995c1e..2f19cad16 100644 --- a/openatlas/__init__.py +++ b/openatlas/__init__.py @@ -60,7 +60,16 @@ def before_request() -> None: g.cidoc_classes = CidocClass.get_all(session['language']) g.properties = CidocProperty.get_all(session['language']) g.classes = OpenatlasClass.get_all() + + from time import perf_counter + start_time = perf_counter() + g.types = Type.get_all() + + end_time = perf_counter() + elapsed_time = end_time - start_time + print(f"Elapsed time: {elapsed_time} seconds") + g.reference_systems = ReferenceSystem.get_all() g.view_class_mapping = view_class_mapping g.class_view_mapping = OpenatlasClass.get_class_view_mapping() diff --git a/openatlas/models/type.py b/openatlas/models/type.py index c84192742..4b88d45cf 100644 --- a/openatlas/models/type.py +++ b/openatlas/models/type.py @@ -117,7 +117,7 @@ def move_entities(self, new_type_id: int, checkbox_values: str) -> None: Db.remove_entity_type(self.id, delete_ids) @staticmethod - def get_all() -> dict[int, Type]: + def get_all(with_count: bool = False) -> dict[int, Type]: types = {} for row in \ Db.get_types('type', 'P127') + \