mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-07 21:38:14 -08:00
chore: Renames output files to include parts for the forms. Finds the number of the form in the filename and change it to a letter equivalent, e.g Part 1 becomes Part A. Only supports 26 parts. If it's already in then correct form (Part A), it makes no alterations.
This commit is contained in:
parent
da99e220c1
commit
747ab0a0b5
1 changed files with 9 additions and 1 deletions
|
|
@ -42,7 +42,15 @@ module Dashboard
|
||||||
row.school.name
|
row.school.name
|
||||||
end.to_set
|
end.to_set
|
||||||
|
|
||||||
part = filepath&.match(/[\b\s_.]+(part|form)[\W*_](?<label>[\w\d])/i)&.named_captures&.[]("label")&.upcase
|
part = filepath&.match(/(part|form)[\W*_\s]*(?<label>[a-zA-Z\d]*)/i)&.named_captures&.[]("label")&.upcase
|
||||||
|
|
||||||
|
# Finds the number of the form and changes it to a letter equivalent, e.g Part 1 becomes Part A. Only supports 26 parts. If it's already in then correct form (Part A), it makes no alterations.
|
||||||
|
if part.present?
|
||||||
|
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
index = part.to_i
|
||||||
|
part = alphabet[index - 1] if index > 0
|
||||||
|
part
|
||||||
|
end
|
||||||
|
|
||||||
school_name = schools.first.parameterize
|
school_name = schools.first.parameterize
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue