mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
chore: Make sure survey items are uniq by survey item ids
This commit is contained in:
parent
1ada4a0bbd
commit
f1eaad62c8
3 changed files with 10 additions and 2 deletions
|
|
@ -7,6 +7,8 @@ class SurveyItem < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :survey_item_responses
|
has_many :survey_item_responses
|
||||||
|
|
||||||
|
validates :survey_item_id, uniqueness: true
|
||||||
|
|
||||||
def score(school:, academic_year:)
|
def score(school:, academic_year:)
|
||||||
@score ||= Hash.new do |memo, (school, academic_year)|
|
@score ||= Hash.new do |memo, (school, academic_year)|
|
||||||
memo[[school, academic_year]] =
|
memo[[school, academic_year]] =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddUniquenessToSurveyItem < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
remove_index :survey_items, :survey_item_id
|
||||||
|
add_index :survey_items, :survey_item_id, unique: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2024_10_31_205926) do
|
ActiveRecord::Schema[8.0].define(version: 2024_11_26_005312) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ ActiveRecord::Schema[8.0].define(version: 2024_10_31_205926) do
|
||||||
t.boolean "on_short_form", default: false
|
t.boolean "on_short_form", default: false
|
||||||
t.integer "survey_item_responses_count"
|
t.integer "survey_item_responses_count"
|
||||||
t.index ["scale_id"], name: "index_survey_items_on_scale_id"
|
t.index ["scale_id"], name: "index_survey_items_on_scale_id"
|
||||||
t.index ["survey_item_id"], name: "index_survey_items_on_survey_item_id"
|
t.index ["survey_item_id"], name: "index_survey_items_on_survey_item_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
add_foreign_key "admin_data_items", "scales"
|
add_foreign_key "admin_data_items", "scales"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue