From eef57de038ecb5ed4d06802d1586ff97374cfbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Fri, 22 Apr 2022 12:20:52 +0100 Subject: [PATCH] Code review changes --- .github/workflows/production_pipeline.yml | 1 - .github/workflows/staging_pipeline.yml | 1 - app/services/imports/case_logs_import_service.rb | 12 +++++++++++- app/services/imports/import_service.rb | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/production_pipeline.yml b/.github/workflows/production_pipeline.yml index d2fb26fd9..09020a74b 100644 --- a/.github/workflows/production_pipeline.yml +++ b/.github/workflows/production_pipeline.yml @@ -180,5 +180,4 @@ jobs: cf set-env $APP_NAME IMPORT_PAAS_INSTANCE $IMPORT_PAAS_INSTANCE cf set-env $APP_NAME EXPORT_PAAS_INSTANCE $EXPORT_PAAS_INSTANCE cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN - cf set-env $APP_NAME RAILS_LOG_TO_STDOUT true cf push $APP_NAME --strategy rolling diff --git a/.github/workflows/staging_pipeline.yml b/.github/workflows/staging_pipeline.yml index 785df00a4..9ba8eee7f 100644 --- a/.github/workflows/staging_pipeline.yml +++ b/.github/workflows/staging_pipeline.yml @@ -148,5 +148,4 @@ jobs: cf set-env $APP_NAME IMPORT_PAAS_INSTANCE $IMPORT_PAAS_INSTANCE cf set-env $APP_NAME EXPORT_PAAS_INSTANCE $EXPORT_PAAS_INSTANCE cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN - cf set-env $APP_NAME RAILS_LOG_TO_STDOUT true cf push $APP_NAME --strategy rolling diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 4f43a34d5..adec47526 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -152,6 +152,16 @@ module Imports attributes["is_la_inferred"] = false # Always keep the given LA attributes["first_time_property_let_as_social_housing"] = first_time_let(attributes["rsnvac"]) + unless attributes["brent"].nil? && + attributes["scharge"].nil? && + attributes["pscharge"].nil? && + attributes["supcharg"].nil? + attributes["brent"] ||= BigDecimal("0.0") + attributes["scharge"] ||= BigDecimal("0.0") + attributes["pscharge"] ||= BigDecimal("0.0") + attributes["supcharg"] ||= BigDecimal("0.0") + end + case_log = CaseLog.new(attributes) case_log.save! compute_differences(case_log, attributes) @@ -178,7 +188,7 @@ module Imports def safe_string_as_decimal(xml_doc, attribute) str = field_value(xml_doc, "xmlns", attribute) if str.blank? - BigDecimal("0.0") + nil else BigDecimal(str, exception: false) end diff --git a/app/services/imports/import_service.rb b/app/services/imports/import_service.rb index 5d0193d93..bd48dc8a3 100644 --- a/app/services/imports/import_service.rb +++ b/app/services/imports/import_service.rb @@ -14,7 +14,7 @@ module Imports xml_document = Nokogiri::XML(file_io) send(create_method, xml_document) rescue StandardError => e - @logger.error "#{e.class} #{e.message}" + @logger.error "#{e.class} in #{filename}: #{e.message}" end end