big roy comment - refactoring the dict per repre_id per project

This commit is contained in:
Kayla Man 2024-11-19 00:19:48 +08:00
parent 0866c00201
commit 004e9626ee

View file

@ -135,7 +135,8 @@ class InventoryModel(QtGui.QStandardItemModel):
self._clear_items()
items_by_repre_id = collections.defaultdict(list)
repre_ids_by_project = collections.defaultdict(set)
item_by_repre_id_by_project_id = collections.defaultdict(
lambda: collections.defaultdict(set))
for container_item in container_items:
# if (
# selected is not None
@ -145,20 +146,17 @@ class InventoryModel(QtGui.QStandardItemModel):
project_name = container_item.project_name
repre_id = container_item.representation_id
items_by_repre_id[repre_id].append(container_item)
repre_ids_by_project[project_name].add(repre_id)
item_by_repre_id_by_project_id[project_name][repre_id].add(container_item)
repre_id = set(items_by_repre_id.keys())
repre_info_by_id = {}
for project_name, repre_ids in repre_ids_by_project.items():
repre_id = set()
for project_name, repre_ids in item_by_repre_id_by_project_id.items():
repre_ids = set(items_by_repre_id.keys())
repre_info = self._controller.get_representation_info_items(
project_name, repre_ids
)
repre_info_by_id.update(repre_info)
product_ids = {
repre_info.product_id
for repre_info in repre_info_by_id.values()
if repre_info.is_valid
}
repre_id.update(repre_ids)
project_products = collections.defaultdict(set)
for container_item in container_items: