Browse Source

Condense logic to update record

pull/2539/head
Manny Dinssa 2 years ago
parent
commit
a9def02e7a
  1. 5
      app/services/csv/lettings_log_csv_service.rb
  2. 5
      app/services/csv/sales_log_csv_service.rb

5
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

5
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

Loading…
Cancel
Save