Skip to content
Browse files

added indexes

  • Loading branch information...
1 parent 9370fda commit ccd06abf95be5c997ad7c922085b486de5fc270c @dbc-apprentice dbc-apprentice committed
View
6 app/models/assignment.rb
@@ -17,12 +17,6 @@ class Assignment < ActiveRecord::Base
scope :by_current, where('due_date >= ?', Date.today)
scope :by_grade, lambda { |grade_level_id| where('grade_level_id = ?', grade_level_id) }
scope :by_subject, lambda { |subject| joins(:subject).where('name = ?', subject) }
-
- # scope :math, joins(:subject).where("name = ?", 'Math')
- # scope :ela, joins(:subject).where("name = ?", 'English Language Arts (ELA)')
- # scope :social_studies, joins(:subject).where("name = ?", 'Social Studies')
- # scope :science, joins(:subject).where("name = ?", 'Science')
- # scope :extra_credit, joins(:subject).where("name = ?", 'Extra Credit')
scope :for_students, joins(:student_assignments)
scope :completed, for_students.where("student_assignments.completion_time IS NOT NULL")
View
5 db/migrate/20120817000554_add_indexes_to_student.rb
@@ -0,0 +1,5 @@
+class AddIndexesToStudent < ActiveRecord::Migration
+ def change
+ add_index :students, :afterschool_class_id
+ end
+end
View
6 db/migrate/20120817001858_add_index_to_attendance.rb
@@ -0,0 +1,6 @@
+class AddIndexToAttendance < ActiveRecord::Migration
+ def change
+ add_index :attendances, :session_id
+ add_index :attendances, :student_id
+ end
+end
View
5 db/migrate/20120817002648_add_index_to_afterschool_class.rb
@@ -0,0 +1,5 @@
+class AddIndexToAfterschoolClass < ActiveRecord::Migration
+ def change
+ add_index :afterschool_classes, :grade_level_id
+ end
+end
View
6 db/migrate/20120817002932_add_index_to_assignment.rb
@@ -0,0 +1,6 @@
+class AddIndexToAssignment < ActiveRecord::Migration
+ def change
+ add_index :assignments, :subject_id
+ add_index :assignments, :grade_level_id
+ end
+end
View
5 db/migrate/20120817003236_add_index_to_session.rb
@@ -0,0 +1,5 @@
+class AddIndexToSession < ActiveRecord::Migration
+ def change
+ add_index :sessions, :afterschool_class_id
+ end
+end
View
6 db/migrate/20120817003613_add_index_to_student_assignment.rb
@@ -0,0 +1,6 @@
+class AddIndexToStudentAssignment < ActiveRecord::Migration
+ def change
+ add_index :student_assignments, :student_id
+ add_index :student_assignments, :assignment_id
+ end
+end
View
5 db/migrate/20120817003836_add_index_to_teacher.rb
@@ -0,0 +1,5 @@
+class AddIndexToTeacher < ActiveRecord::Migration
+ def change
+ add_index :teachers, :afterschool_class_id
+ end
+end
View
19 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120813173500) do
+ActiveRecord::Schema.define(:version => 20120817003836) do
create_table "admins", :force => true do |t|
t.string "email", :default => "", :null => false
@@ -37,6 +37,8 @@
t.datetime "updated_at", :null => false
end
+ add_index "afterschool_classes", ["grade_level_id"], :name => "index_afterschool_classes_on_grade_level_id"
+
create_table "assignments", :force => true do |t|
t.string "description"
t.date "due_date"
@@ -47,6 +49,9 @@
t.integer "grade_level_id"
end
+ add_index "assignments", ["grade_level_id"], :name => "index_assignments_on_grade_level_id"
+ add_index "assignments", ["subject_id"], :name => "index_assignments_on_subject_id"
+
create_table "attendances", :force => true do |t|
t.integer "session_id"
t.integer "student_id"
@@ -55,6 +60,9 @@
t.datetime "updated_at", :null => false
end
+ add_index "attendances", ["session_id"], :name => "index_attendances_on_session_id"
+ add_index "attendances", ["student_id"], :name => "index_attendances_on_student_id"
+
create_table "grade_levels", :force => true do |t|
t.string "year"
t.datetime "created_at", :null => false
@@ -69,6 +77,8 @@
t.datetime "updated_at", :null => false
end
+ add_index "sessions", ["afterschool_class_id"], :name => "index_sessions_on_afterschool_class_id"
+
create_table "student_assignments", :force => true do |t|
t.datetime "completion_time"
t.integer "student_id"
@@ -77,6 +87,9 @@
t.datetime "updated_at", :null => false
end
+ add_index "student_assignments", ["assignment_id"], :name => "index_student_assignments_on_assignment_id"
+ add_index "student_assignments", ["student_id"], :name => "index_student_assignments_on_student_id"
+
create_table "students", :force => true do |t|
t.string "first_name"
t.string "last_name"
@@ -85,6 +98,8 @@
t.datetime "updated_at", :null => false
end
+ add_index "students", ["afterschool_class_id"], :name => "index_students_on_afterschool_class_id"
+
create_table "subjects", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
@@ -100,4 +115,6 @@
t.string "salutation"
end
+ add_index "teachers", ["afterschool_class_id"], :name => "index_teachers_on_afterschool_class_id"
+
end

0 comments on commit ccd06ab

Please sign in to comment.
Something went wrong with that request. Please try again.