From 5c6dbb309a339b242f3135987f94dc0a1cb0aebb Mon Sep 17 00:00:00 2001 From: Christoph Franke Date: Wed, 11 Dec 2019 10:20:07 +0100 Subject: [PATCH 1/2] fixed base graph date --- repair/js/strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repair/js/strategy.js b/repair/js/strategy.js index 80ee93c5a..ef47d41ce 100644 --- a/repair/js/strategy.js +++ b/repair/js/strategy.js @@ -123,7 +123,7 @@ require(['models/casestudy', 'models/gdsemodel', 'collections/gdsecollection', var btn = document.getElementById('build-graph'), note = document.getElementById('graph-note'), clone = btn.cloneNode(true); - note.innerHTML = keyflow.get('graph_build') || '-'; + note.innerHTML = keyflow.get('graph_date') || '-'; btn.parentNode.replaceChild(clone, btn); clone.addEventListener('click', function(){ loader.activate(); From 855a2ce743b7982ce261d017177ec68551d875c9 Mon Sep 17 00:00:00 2001 From: Christoph Franke Date: Wed, 11 Dec 2019 11:22:42 +0100 Subject: [PATCH 2/2] optimized speed of building base graph; fixed unsetting questions of parts --- repair/apps/asmfa/graphs/graph.py | 34 +++++++++++--------- repair/apps/changes/serializers/solutions.py | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/repair/apps/asmfa/graphs/graph.py b/repair/apps/asmfa/graphs/graph.py index e251701db..52bee4941 100644 --- a/repair/apps/asmfa/graphs/graph.py +++ b/repair/apps/asmfa/graphs/graph.py @@ -202,8 +202,8 @@ def build(self): Q(id__in=actorflows.values('origin_id')) | Q(id__in=actorflows.values('destination_id')) | Q(id__in=stockflows.values('origin_id')) - ) - flows = list(chain(actorflows, stockflows)) + ).values() + flows = list(chain(actorflows.values(), stockflows.values())) self.graph = gt.Graph(directed=True) @@ -220,10 +220,11 @@ def build(self): actorids = {} for i in range(len(actors)): - self.graph.vp.id[i] = actors[i].id - self.graph.vp.bvdid[i] = actors[i].BvDid - self.graph.vp.name[i] = actors[i].name - actorids[actors[i].id] = i + actor_id = actors[i]['id'] + self.graph.vp.id[i] = actors[i]['id'] + self.graph.vp.bvdid[i] = actors[i]['BvDid'] + self.graph.vp.name[i] = actors[i]['name'] + actorids[actor_id] = i # Add the flows to the graph # need a persistent edge id, because graph-tool can reindex the edges @@ -242,22 +243,23 @@ def build(self): for i in range(len(flows)): # get the start and and actor id's flow = flows[i] - v0 = actorids.get(flow.origin.id) - if not flow.to_stock: - v1 = actorids.get(flow.destination.id) + v0 = actorids.get(flow['origin_id']) + if not flow['to_stock']: + v1 = actorids.get(flow['destination_id']) else: v1 = v0 if (v0 != None and v1 != None): e = self.graph.add_edge( self.graph.vertex(v0), self.graph.vertex(v1)) - self.graph.ep.id[e] = flow.id - self.graph.ep.material[e] = flow.material_id - self.graph.ep.waste[e] = flow.waste - self.graph.ep.hazardous[e] = flow.hazardous - self.graph.ep.process[e] = \ - flow.process_id if flow.process_id is not None else - 1 - self.graph.ep.amount[e] = flow.amount + self.graph.ep.id[e] = flow['id'] + self.graph.ep.material[e] = flow['material_id'] + self.graph.ep.waste[e] = flow['waste'] + self.graph.ep.hazardous[e] = flow['hazardous'] + process_id = flow['process_id'] + self.graph.ep.process[e] = process_id\ + if process_id is not None else - 1 + self.graph.ep.amount[e] = flow['amount'] # get the original order of the vertices and edges in the graph edge_index = np.fromiter(self.graph.edge_index, dtype=int) diff --git a/repair/apps/changes/serializers/solutions.py b/repair/apps/changes/serializers/solutions.py index 0cbac8b01..c09aed611 100644 --- a/repair/apps/changes/serializers/solutions.py +++ b/repair/apps/changes/serializers/solutions.py @@ -340,7 +340,7 @@ def update(self, instance, validated_data): affected_flows = validated_data.pop('affected_flows', None) flow_reference = validated_data.pop('flow_reference', None) flow_changes = validated_data.pop('flow_changes', None) - question = validated_data.pop('question', None) + question = validated_data.get('question', None) instance = super().update(instance, validated_data) if flow_reference: if instance.flow_reference: