bellotastudios/gradecraft-development — pull request #364 by allspiritseve (2013-09-17 02:49:03+00:00)
Title: Feedback needed: Performance improvements

The slowest sections on the student dashboard are the syllabus and the predictor. This pull request focuses on the predictor, where I got `app/views/users/_predictor.html.haml` from 3-5 seconds down to 100-400ms.

I created two new models, `StudentData` and `CourseData`. These models lazy load expensive operations and then cache them in instance variables. For example:

```ruby
# app/models/student_score.rb
def score
@score ||= released_grades.where(course: course).score
end
```
Usage:
```ruby
# app/views/users/_predictor.html.haml
= current_student_data.score
```

I'm hoping this will fit naturally with the database improvements @bigeasy is making.

Any and all feedback is welcome!