Browse Source

Refactor IF

pull/2539/head
Manny Dinssa 2 years ago
parent
commit
485a732e2e
  1. 9
      app/services/imports/variable_definitions_service.rb

9
app/services/imports/variable_definitions_service.rb

@ -35,11 +35,8 @@ module Imports
next if variable.nil? || definition.nil? next if variable.nil? || definition.nil?
existing_record = CsvVariableDefinition.find_by(variable: variable.strip, definition: definition.strip, log_type:) existing_record = CsvVariableDefinition.find_by(variable: variable.strip, definition: definition.strip, log_type:)
if existing_record
if user_type == "user" && existing_record.user_type == "support" if existing_record.nil?
existing_record.update!(user_type: "user")
end
else
CsvVariableDefinition.create!( CsvVariableDefinition.create!(
variable: variable.strip, variable: variable.strip,
definition: definition.strip, definition: definition.strip,
@ -48,6 +45,8 @@ module Imports
year:, year:,
) )
records_added += 1 records_added += 1
elsif existing_record.user_type == "support" && user_type == "user"
existing_record.update!(user_type: "user")
end end
end end

Loading…
Cancel
Save