mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-07 13:38:12 -08:00
chore: seed framework
This commit is contained in:
parent
cd7b05df73
commit
27550e0b30
10 changed files with 83 additions and 82 deletions
|
|
@ -6,7 +6,7 @@ module Dashboard
|
|||
academic_years << { range: }
|
||||
end
|
||||
|
||||
AcademicYear.insert_all(academic_years, unique_by: [:id])
|
||||
AcademicYear.upsert_all(academic_years)
|
||||
end
|
||||
|
||||
def seed_districts_and_schools(csv_file)
|
||||
|
|
@ -30,7 +30,7 @@ module Dashboard
|
|||
is_hs: marked?(hs), slug: school_name.parameterize }
|
||||
end
|
||||
|
||||
School.upsert_all(schools)
|
||||
School.insert_all(schools)
|
||||
|
||||
Respondent.joins(:school).where.not("school.dese_id": dese_ids).destroy_all
|
||||
School.where.not(dese_id: dese_ids).destroy_all
|
||||
|
|
@ -93,7 +93,7 @@ module Dashboard
|
|||
end
|
||||
end
|
||||
|
||||
AdminDataValue.where.not(admin_data_item_id: admin_data_item_ids).delete_all
|
||||
AdminDataValue.where.not(admin_data_item: admin_data_item_ids).delete_all
|
||||
AdminDataItem.where.not(id: admin_data_item_ids).delete_all
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Dashboard
|
||||
class AdminDataItem < ApplicationRecord
|
||||
belongs_to :dashboard_scale
|
||||
has_many :dashboard_admin_data_values
|
||||
belongs_to :scale, class_name: "Scale", foreign_key: :dashboard_scale_id
|
||||
has_many :admin_data_values, class_name: "AdminDataValue", foreign_key: :dashboard_admin_data_item_id
|
||||
|
||||
scope :for_measures, lambda { |measures|
|
||||
joins(:scale).where('scale.measure': measures)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
module Dashboard
|
||||
class AdminDataValue < ApplicationRecord
|
||||
belongs_to :school
|
||||
belongs_to :dashboard_admin_data_item
|
||||
belongs_to :dashboard_academic_year
|
||||
belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id
|
||||
belongs_to :admin_data_item, class_name: "AdminDataItem", foreign_key: :dashboard_admin_data_item_id
|
||||
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id
|
||||
|
||||
validates :likert_score, numericality: { greater_than: 0, less_than_or_equal_to: 5 }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module Dashboard
|
|||
|
||||
scope :sorted, -> { order(:category_id) }
|
||||
|
||||
has_many :subcategories, class_name: "Subcategory", foreign_key: :dashboard_category_id
|
||||
has_many :subcategories, class_name: "Subcategory", foreign_key: :dashboard_categories_id
|
||||
has_many :measures, through: :subcategories
|
||||
has_many :admin_data_items, through: :measures
|
||||
has_many :scales, through: :subcategories
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module Dashboard
|
||||
class Measure < ApplicationRecord
|
||||
belongs_to :dashboard_subcategory
|
||||
belongs_to :subcategory, class_name: "Subcategory", foreign_key: :dashboard_subcategory_id
|
||||
has_one :dashboard_category, through: :dashboard_subcategory
|
||||
has_many :dashboard_scales
|
||||
has_many :dashboard_admin_data_items, through: :scales
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
module Dashboard
|
||||
class Scale < ApplicationRecord
|
||||
belongs_to :dashboard_measure
|
||||
has_many :dashboard_survey_items
|
||||
has_many :dashboard_survey_item_responses, through: :dashboard_survey_items
|
||||
has_many :dashboard_admin_data_items
|
||||
belongs_to :measure, class_name: "Measure", foreign_key: :dashboard_measure_id
|
||||
has_many :survey_items
|
||||
has_many :survey_item_responses, through: :survey_items
|
||||
has_many :admin_data_items, class_name: "AdminDataItem", foreign_key: :admin_data_item_id
|
||||
|
||||
def score(school:, academic_year:)
|
||||
@score ||= Hash.new do |memo, (school, academic_year)|
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Dashboard
|
||||
class StudentResponseRateCalculator < ResponseRateCalculator
|
||||
def raw_response_rate
|
||||
rates_by_grade.values.length.positive? ? weighted_average : 0
|
||||
|
|
@ -65,3 +66,4 @@ class StudentResponseRateCalculator < ResponseRateCalculator
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
module Dashboard
|
||||
class Subcategory < ApplicationRecord
|
||||
belongs_to :category, class_name: "Category", foreign_key: :dashboard_category_id
|
||||
belongs_to :category, class_name: "Category", foreign_key: :dashboard_categories_id
|
||||
|
||||
has_many :dashboard_measures
|
||||
has_many :dashboard_survey_items, through: :dashboard_measures
|
||||
has_many :dashboard_admin_data_items, through: :dashboard_measures
|
||||
has_many :dashboard_survey_items, through: :dashboard_measures
|
||||
has_many :dashboard_scales, through: :dashboard_measures
|
||||
has_many :measures, class_name: "Measure", foreign_key: :dashboard_subcategory_id
|
||||
has_many :survey_items, through: :measures
|
||||
has_many :admin_data_items, through: :measures
|
||||
has_many :survey_items, through: :measures
|
||||
has_many :scales, through: :measures
|
||||
|
||||
def score(school:, academic_year:)
|
||||
measures.map do |measure|
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
module Dashboard
|
||||
class SurveyItem < ApplicationRecord
|
||||
# belongs_to :dashboard_scale
|
||||
belongs_to :scale, class_name: "Scale", foreign_key: :dashboard_scale_id
|
||||
has_many :survey_item_responses, class_name: "SurveyItemResponse", foreign_key: :dashboard_survey_item_id
|
||||
|
||||
# has_one :dashboard_measure, through: dashboard_scale
|
||||
# has_one :dashboard_subcategory, through: dashboard_measure
|
||||
|
||||
has_many :dashboard_survey_item_responses
|
||||
has_one :measure, through: :scale
|
||||
has_one :subcategory, through: :measure
|
||||
|
||||
def score(school:, academic_year:)
|
||||
@score ||= Hash.new do |memo, (school, academic_year)|
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace :dashboard do
|
|||
"2023-24"
|
||||
seeder.seed_districts_and_schools Dashboard::Engine.root.join("data", "dashboard",
|
||||
"master_list_of_schools_and_districts.csv")
|
||||
# seeder.seed_sqm_framework Dashboard::Engine.root.join("data", "dashboard", "sqm_framework.csv")
|
||||
seeder.seed_sqm_framework Dashboard::Engine.root.join("data", "dashboard", "sqm_framework.csv")
|
||||
# seeder.seed_demographics Rails.root.join("data", "demographics.csv")
|
||||
# seeder.seed_enrollment Rails.root.join("data", "enrollment", "enrollment.csv")
|
||||
# seeder.seed_enrollment Rails.root.join("data", "enrollment", "nj_enrollment.csv")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue