Skip to content

Commit

Permalink
fixed another bug resulting from loading plans that refer to operatio…
Browse files Browse the repository at this point in the history
…n types have been deleted
  • Loading branch information
klavins committed Sep 21, 2017
1 parent 18302bf commit 670bada
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions app/assets/javascripts/models/marshall.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ AQ.Operation.record_methods.marshall = function() {
}

// op.operation_type = AQ.OperationType.record(op.operation_type).marshall();
var ots = aq.where(AQ.operation_types, ot => ot.id == op.operation_type_id);
var ots = aq.where(AQ.operation_types, ot => ot.deployed && ot.id == op.operation_type_id);

if ( ots.length != 1 ) {
console.log("WARNING: Could not find operation types in AQ. Make sure AQ.operation_types is initialized")
alert("Operation " + op.id + " does not have a (deployed) operation type. Skipping.")
console.log("WARNING: Could not find operation types in AQ. Make sure AQ.operation_types is initialized");
return null;
} else {
op.operation_type = ots[0];
}
Expand Down Expand Up @@ -131,9 +133,22 @@ AQ.Operation.record_methods.marshall = function() {
AQ.Plan.record_methods.marshall = function() {

var plan = this;
plan.operations = aq.collect(plan.operations, (op) => AQ.Operation.record(op).marshall());

var marshalled_operations = [];

aq.each(plan.operations, op => {
var op = AQ.Operation.record(op).marshall();
if ( op ) {
marshalled_operations.push(op);
}
});

plan.operations = marshalled_operations;

plan.wires = aq.collect(plan.wires, wire => AQ.Wire.record(wire));

var skip_wires = [];

aq.each(plan.wires, w => {
w.snap = 16;
aq.each(plan.operations, o => {
Expand All @@ -153,9 +168,15 @@ AQ.Plan.record_methods.marshall = function() {
o.recompute_getter("types_and_values")
o.recompute_getter('num_inputs');
o.recompute_getter('num_outputs');
})
});
if ( !w.to || !w.from ) {
skip_wires.push(w);
console.log("WARNING: Skipping wire, probably because operation was deleted.")
}
})

plan.wires = aq.where(plan.wires, w => !skip_wires.includes(w));

plan.layout = plan.marshall_layout();
plan.open = true;
return plan;
Expand Down

0 comments on commit 670bada

Please sign in to comment.