chore: bring in some refactoring changes that didn't get copied over from the main branch

This commit is contained in:
Nelson Jovel 2023-12-20 19:27:06 -08:00
parent 75451648e5
commit 2a125aa058
5 changed files with 61 additions and 57 deletions

View file

@ -4,4 +4,14 @@ class Ell < ApplicationRecord
include FriendlyId
friendly_id :designation, use: [:slugged]
def self.to_designation(ell)
case ell
in /lep student 1st year|LEP student not 1st year|EL Student First Year|LEP\s*student/i
"ELL"
in /Does not apply/i
"Not ELL"
else
"Unknown"
end
end
end

View file

@ -6,14 +6,24 @@ class Income < ApplicationRecord
friendly_id :designation, use: [:slugged]
def label
case designation
when "Economically Disadvantaged - Y"
"Economically Disadvantaged"
when "Economically Disadvantaged - N"
"Not Economically Disadvantaged"
when "Unknown"
def self.to_designation(income)
case income
in /Free\s*Lunch|Reduced\s*Lunch|Low\s*Income|Reduced\s*price\s*lunch/i
"Economically Disadvantaged - Y"
in /Not\s*Eligible/i
"Economically Disadvantaged - N"
else
"Unknown"
end
end
LABELS = {
"Economically Disadvantaged - Y" => "Economically Disadvantaged",
"Economically Disadvantaged - N" => "Not Economically Disadvantaged",
"Unknown" => "Unknown"
}
def label
LABELS[designation]
end
end

View file

@ -33,17 +33,17 @@ class Race < ApplicationRecord
end
end
def self.normalize_race_list(codes)
def self.normalize_race_list(codes)
# if anyone selects not to disclose their race or prefers to self-describe, categorize that as unknown race
races = codes.map do |code|
code = 99 if [6, 7].include?(code) || code.nil? || code.zero?
code
end.uniq
races.delete(99) if races.length > 1 #remove unkown race if other races present
races.delete(99) if races.length > 1 # remove unkown race if other races present
races << 100 if races.length > 1 # add multiracial designation if multiple races present
races << 99 if races.length == 0 # add unknown race if other races missing
races
end
end

View file

@ -4,4 +4,14 @@ class Sped < ApplicationRecord
include FriendlyId
friendly_id :designation, use: [:slugged]
def self.to_designation(sped)
case sped
in /active/i
"Special Education"
in /^NA$|^#NA$/i
"Unknown"
else
"Not Special Education"
end
end
end