sqm-dashboards/app/models/language.rb
rebuilt 0f457becf0 feat: create a parents by language graph
Update demographics table with lanugage options

Create a lanugage table to hold the new languages

Update the demographic loader to input languages into the database

Update the cleaner to read the language column

Update the parent table to hold a reference to a language

Update the data uploader script to read the language from the csv and update the language information for any parent items that already exist (or create database entries if none already exist)

update the analyze interface to add controls for selecting ‘parents by group’ and a dropdown for ‘parent by language’

Update the analyze controller to read the parent-by-group parameter

Create a graph for the parent-by-group view

Bubble up averages for language calculations.

Make sure n-size only counts responses for a given measure.
2025-04-28 16:42:11 -07:00

33 lines
926 B
Ruby

class Language < ApplicationRecord
scope :by_designation, -> { all.map { |language| [language.designation, language] }.to_h }
has_many :parent_languages, dependent: :destroy
has_many :parents, through: :parent_languages, dependent: :nullify
include FriendlyId
friendly_id :designation, use: [:slugged]
def self.to_designation(language)
return "Prefer not to disclose" if language.blank?
case language
in /^1$/i
"English"
in /^2$/i
"Portuguese"
in /^3$/i
"Spanish"
in /^99$/i
"Prefer not to disclose"
in /|^100$/i
"Prefer to self-describe"
else
puts "************************************"
puts "******** ERROR **********"
puts ""
puts "Error parsing Language column. '#{language}' is not a known value. Halting execution"
puts ""
puts "************************************"
exit
end
end
end