aboutsummaryrefslogtreecommitdiffstats
path: root/app/workers
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/compliance_control_set_copy_worker.rb3
-rw-r--r--app/workers/route_way_cost_worker.rb6
-rw-r--r--app/workers/workbench_import_worker/object_state_updater.rb17
3 files changed, 20 insertions, 6 deletions
diff --git a/app/workers/compliance_control_set_copy_worker.rb b/app/workers/compliance_control_set_copy_worker.rb
index d18bb0c88..b87f5ad8e 100644
--- a/app/workers/compliance_control_set_copy_worker.rb
+++ b/app/workers/compliance_control_set_copy_worker.rb
@@ -1,8 +1,9 @@
class ComplianceControlSetCopyWorker
include Sidekiq::Worker
- def perform(control_set_id, referential_id)
+ def perform(control_set_id, referential_id, parent_type = nil, parent_id = nil)
check_set = ComplianceControlSetCopier.new.copy(control_set_id, referential_id)
+ check_set.update parent_type: parent_type, parent_id: parent_id if parent_type && parent_id
begin
Net::HTTP.get(URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{check_set.id}"))
diff --git a/app/workers/route_way_cost_worker.rb b/app/workers/route_way_cost_worker.rb
index b62416c3d..5d8ed52f9 100644
--- a/app/workers/route_way_cost_worker.rb
+++ b/app/workers/route_way_cost_worker.rb
@@ -3,7 +3,11 @@ class RouteWayCostWorker
def perform(referential_id, route_id)
Referential.find(referential_id).switch
- route = Chouette::Route.find(route_id)
+ route = Chouette::Route.where(id: route_id).last
+ unless route.present?
+ Rails.logger.warn "RouteWayCost called on missing route ##{route_id}".red
+ return
+ end
# Prevent recursive worker spawning since this call updates the
# `costs` field of the route.
diff --git a/app/workers/workbench_import_worker/object_state_updater.rb b/app/workers/workbench_import_worker/object_state_updater.rb
index 1edc6b9a1..39d5f20b1 100644
--- a/app/workers/workbench_import_worker/object_state_updater.rb
+++ b/app/workers/workbench_import_worker/object_state_updater.rb
@@ -2,6 +2,11 @@
class WorkbenchImportWorker
module ObjectStateUpdater
+ def resource entry
+ @_resources ||= {}
+ @_resources[entry.name] ||= workbench_import.resources.find_or_create_by(name: entry.name, resource_type: "referential")
+ end
+
def update_object_state entry, count
workbench_import.update( total_steps: count )
update_spurious entry
@@ -14,44 +19,48 @@ class WorkbenchImportWorker
def update_foreign_lines entry
return if entry.foreign_lines.empty?
- workbench_import.messages.create(
+ resource(entry).messages.create(
criticity: :error,
message_key: 'foreign_lines_in_referential',
message_attributes: {
'source_filename' => workbench_import.file.file.file,
'foreign_lines' => entry.foreign_lines.join(', ')
})
+ resource(entry).update status: :ERROR
end
def update_spurious entry
return if entry.spurious.empty?
- workbench_import.messages.create(
+ resource(entry).messages.create(
criticity: :error,
message_key: 'inconsistent_zip_file',
message_attributes: {
'source_filename' => workbench_import.file.file.file,
'spurious_dirs' => entry.spurious.join(', ')
})
+ resource(entry).update status: :ERROR
end
def update_missing_calendar entry
return unless entry.missing_calendar
- workbench_import.messages.create(
+ resource(entry).messages.create(
criticity: :error,
message_key: 'missing_calendar_in_zip_file',
message_attributes: {
'source_filename' => entry.name
})
+ resource(entry).update status: :ERROR
end
def update_wrong_calendar entry
return unless entry.wrong_calendar
- workbench_import.messages.create(
+ resource(entry).messages.create(
criticity: :error,
message_key: 'wrong_calendar_in_zip_file',
message_attributes: {
'source_filename' => entry.name
})
+ resource(entry).update status: :ERROR
end
end
end