Browse Source

CLDC-3911 Limit CSV variables to those defined in or before year (#2982)

* don't use variables from the future

* filter out nil elements for vars only defined in future

* only group variables by name, not by description

---------

Co-authored-by: Carolyn <carolyn.barker@softwire.com>
pull/2992/head
carolynbarker 1 week ago committed by GitHub
parent
commit
772b1fcd68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      app/services/csv/lettings_log_csv_service.rb
  2. 7
      app/services/csv/sales_log_csv_service.rb

7
app/services/csv/lettings_log_csv_service.rb

@ -284,13 +284,12 @@ module Csv
end
def lettings_log_definitions
CsvVariableDefinition.lettings.group_by { |record| [record.variable, record.definition] }
.map do |_, options|
CsvVariableDefinition.lettings.group_by(&:variable).map { |_, options|
exact_match = options.find { |definition| definition.year == @year }
next exact_match if exact_match
options.max_by(&:year)
end
options.select { |opt| opt.year < @year }.max_by(&:year)
}.compact
end
def insert_derived_and_related_attributes(ordered_questions)

7
app/services/csv/sales_log_csv_service.rb

@ -179,13 +179,12 @@ module Csv
end
def sales_log_definitions
CsvVariableDefinition.sales.group_by { |record| [record.variable, record.definition] }
.map do |_, options|
CsvVariableDefinition.sales.group_by(&:variable).map { |_, options|
exact_match = options.find { |definition| definition.year == @year }
next exact_match if exact_match
options.max_by(&:year)
end
options.select { |opt| opt.year < @year }.max_by(&:year)
}.compact
end
def insert_derived_and_related_attributes(ordered_questions)

Loading…
Cancel
Save