chore: seed academic years, districts and schools

This commit is contained in:
Nelson Jovel 2024-01-11 14:34:17 -08:00
parent 30f9f05a63
commit cd7b05df73
94 changed files with 697970 additions and 14 deletions

View file

@ -5,7 +5,7 @@ module Dashboard
scope :sorted, -> { order(:category_id) }
has_many :subcategories
has_many :subcategories, class_name: "Subcategory", foreign_key: :dashboard_category_id
has_many :measures, through: :subcategories
has_many :admin_data_items, through: :measures
has_many :scales, through: :subcategories

View file

@ -1,6 +1,6 @@
module Dashboard
class District < ApplicationRecord
has_many :schools, class_name: "School", foreign_key: :id
has_many :schools, class_name: "School", foreign_key: :dashboard_district_id
validates :name, presence: true

View file

@ -1,7 +1,7 @@
module Dashboard
class Respondent < ApplicationRecord
belongs_to :school
belongs_to :dashboard_academic_year
belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id
validates :school, uniqueness: { scope: :academic_year }

View file

@ -1,5 +1,8 @@
module Dashboard
class School < ApplicationRecord
include FriendlyId
friendly_id :name, use: :slugged
belongs_to :district, class_name: "District", foreign_key: :dashboard_district_id
# has_many :dashboard_survey_item_responses, dependent: :delete_all
@ -9,9 +12,6 @@ module Dashboard
scope :alphabetic, -> { order(name: :asc) }
scope :school_hash, -> { all.map { |school| [school.dese_id, school] }.to_h }
include FriendlyId
friendly_id :name, use: [:slugged]
def self.find_by_district_code_and_school_code(district_code, school_code)
School
.joins(:district)

View file

@ -1,6 +1,6 @@
module Dashboard
class Subcategory < ApplicationRecord
belongs_to :dashboard_categories, class_name: "Dashboard::Category"
belongs_to :category, class_name: "Category", foreign_key: :dashboard_category_id
has_many :dashboard_measures
has_many :dashboard_survey_items, through: :dashboard_measures