diff --git a/api/v01/vrp.rb b/api/v01/vrp.rb index 0f709af7..0f7fd58e 100644 --- a/api/v01/vrp.rb +++ b/api/v01/vrp.rb @@ -235,7 +235,7 @@ class Vrp < APIBase graph: result_object[:graph] }, geojsons: OutputHelper::Result.generate_geometry(result_object) - }, with: VrpResult, detailed_solutions: job&.status&.to_sym == :completed || result_object.dig(:configuration, :intermediate_solutions)) + }, with: VrpResult, detailed_solutions: job.nil? || job.status&.to_sym == :completed || result_object.dig(:configuration, :intermediate_solutions)) end # set nil to release memory because puma keeps the grape api endpoint object alive stored_result = nil # rubocop:disable Lint/UselessAssignment diff --git a/models/vrp.rb b/models/vrp.rb index e213e926..0f3a00f2 100644 --- a/models/vrp.rb +++ b/models/vrp.rb @@ -309,7 +309,9 @@ def self.convert_position_relations(hash) r[:linked_service_ids]&.each{ |id| to_modify = hash[:services].find{ |s| s[:id] == id } - raise OptimizerWrapper::DiscordantProblemError.new(r[:type].to_s + error_msg) unless to_modify[:activity] + if to_modify.nil? || !to_modify.key?(:activity) + raise OptimizerWrapper::DiscordantProblemError.new(r[:type].to_s + error_msg) + end to_modify[:activity][:position] = type_conversion[r[:type]] }