mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 15:38:21 -07:00
ECP-77 Make sure admin data seeder updates the description from the latest column
This commit is contained in:
parent
ee4fec12fa
commit
9bf8f3650c
3 changed files with 125 additions and 110 deletions
|
|
@ -116,7 +116,7 @@ class Seeder
|
|||
admin_data_item.growth_low_benchmark = growth_low if growth_low
|
||||
admin_data_item.approval_low_benchmark = approval_low if approval_low
|
||||
admin_data_item.ideal_low_benchmark = ideal_low if ideal_low
|
||||
admin_data_item.description = row["Question/item (22-23)"]&.strip
|
||||
admin_data_item.description = value_from(pattern: /^Question\/item\s\(.*\)/i , row:)
|
||||
admin_data_item.hs_only_item = marked? row["HS only admin item?"]
|
||||
admin_data_item.save!
|
||||
admin_data_item_ids << admin_data_item.id
|
||||
|
|
@ -148,6 +148,15 @@ class Seeder
|
|||
end
|
||||
|
||||
private
|
||||
def value_from(pattern:, row:)
|
||||
matches = row.headers.select do |header|
|
||||
pattern.match(header)
|
||||
end
|
||||
|
||||
# Sort in descending order so highest comes first
|
||||
header = matches.sort {|x,y| y <=> x}.first
|
||||
row[header]
|
||||
end
|
||||
|
||||
def marked?(mark)
|
||||
mark.present? ? mark.upcase.strip == "X" : false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue