diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index c5f0a5357..490b89416 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/app/services/csv/lettings_log_csv_service.rb @@ -13,10 +13,7 @@ module Csv if @year >= 2023 csv << @attributes.map do |attribute| record = @definitions.find { |r| r.variable == attribute.downcase } - if record - record.update!(last_accessed: Time.zone.now) - record.definition - end + record&.tap { |r| r.update!(last_accessed: Time.zone.now) }&.definition end end csv << @attributes diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index 6762f50c1..7f17d86cc 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/app/services/csv/sales_log_csv_service.rb @@ -14,10 +14,7 @@ module Csv if @year >= 2023 csv << formatted_attributes.map do |attribute| record = @definitions.find { |r| r.variable == attribute.downcase } - if record - record.update!(last_accessed: Time.zone.now) - record.definition - end + record&.tap { |r| r.update!(last_accessed: Time.zone.now) }&.definition end end csv << formatted_attributes