Faster admin data loader + rename School.school_hash

This commit is contained in:
Gabe Farrell 2024-04-22 14:46:37 -04:00
parent 0965841566
commit b3e6efdb2e
7 changed files with 128 additions and 77 deletions

View file

@ -8,7 +8,7 @@ class School < ApplicationRecord
validates :name, presence: true
scope :alphabetic, -> { order(name: :asc) }
scope :school_hash, -> { all.map { |school| [school.dese_id, school] }.to_h }
scope :school_by_dese_id, -> { all.map { |school| [school.dese_id, school] }.to_h }
include FriendlyId
friendly_id :name, use: [:slugged]
@ -16,7 +16,7 @@ class School < ApplicationRecord
def self.find_by_district_code_and_school_code(district_code, school_code)
School
.joins(:district)
.where(districts: { qualtrics_code: district_code })
.where(districts: {qualtrics_code: district_code})
.find_by_qualtrics_code(school_code)
end