Created
July 2, 2009 17:41
-
-
Save wallace/139605 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def list_sessions | |
| @category_id = params[:category_id] | |
| @course_id = params[:course_id] || "" | |
| @end_date = params[:end_date] ||= "" | |
| # get the student group assets | |
| conditions = ["course_sessions.is_active = ? and course_sessions.in_catalog = ? and courses.in_catalog = ?"] | |
| vars = [true, true, true] | |
| options = {} | |
| student_entries = GroupCourseSession.find(:all, | |
| :select => "group_course_sessions.course_session_id", | |
| :joins => "join group_members on group_members.group_id = group_course_sessions.group_id | |
| and group_members.user_id = #{@current_user.id}" | |
| ) | |
| if student_entries.empty? | |
| conditions << "course_sessions.is_restricted = 'f'" | |
| else | |
| conditions << "(course_sessions.is_restricted = 'f' | |
| or course_sessions.id in (#{ student_entries.map(&:course_session_id).uniq.join(",") }))" | |
| end | |
| # if there is a course supplied we only look at sessions of this course | |
| conditions << "course_sessions.course_id = ?" unless params[:course_id].blank? | |
| vars << params[:course_id] unless params[:course_id].blank? | |
| # only show future courses | |
| conditions << "course_sessions.start_on >= ?" | |
| vars << Time.now.beginning_of_day | |
| unless @end_date.blank? | |
| conditions << "course_sessions.end_on <= ?" | |
| vars << Time.now.beginning_of_day + @end_date.to_i.days | |
| end | |
| unless @category_id.blank? | |
| conditions << "category_tags.category_id = ?" | |
| vars << @category_id | |
| end | |
| # look for all of the accounts sessions | |
| options = {:conditions => [conditions.join(" and ")] + vars, | |
| :include => [:course], | |
| :page => {:size => 50, :current => params[:page], :first => 1}, | |
| :order => "course_sessions.start_on"} | |
| unless @category_id.blank? | |
| options[:joins] = "join category_tags on category_tags.categorizable_type = 'Course' and category_tags.categorizable_id = courses.id" | |
| end | |
| @sessions = @account.course_sessions.find(:all, options) | |
| @course_options = CourseInstructorLed.find(:all, | |
| :conditions => ["account_id = ? and is_active = ?", @account.id, true]).collect {|c| [c.name, c.id]} | |
| @categories = @account.categories.find(:all, | |
| :conditions => "id in (select distinct(category_id) from category_tags where categorizable_type = 'Course')", | |
| :order => "name") | |
| @page_title = "Catalog Home" | |
| @page_column = {:partial => "list_sessions_side"} | |
| end | |
| [152, 161] in /var/www/rails/rollbook/releases/20090702165857/app/controllers/catalog_controller.rb | |
| 152 unless @category_id.blank? | |
| 153 options[:joins] = "join category_tags on category_tags.categorizable_type = 'Course' and category_tags.categorizable_id = courses.id" | |
| 154 end | |
| 155 | |
| 156 debugger | |
| => 157 @sessions = @account.course_sessions.find(:all, options) | |
| 158 | |
| 159 @course_options = CourseInstructorLed.find(:all, | |
| 160 :conditions => ["account_id = ? and is_active = ?", @account.id, true]).collect {|c| [c.name, c.id]} | |
| 161 | |
| (rdb:1) n | |
| [154, 163] in /var/www/rails/rollbook/releases/20090702165857/app/controllers/catalog_controller.rb | |
| 154 end | |
| 155 | |
| 156 debugger | |
| 157 @sessions = @account.course_sessions.find(:all, options) | |
| 158 | |
| => 159 @course_options = CourseInstructorLed.find(:all, | |
| 160 :conditions => ["account_id = ? and is_active = ?", @account.id, true]).collect {|c| [c.name, c.id]} | |
| 161 | |
| 162 @categories = @account.categories.find(:all, | |
| 163 :conditions => "id in (select distinct(category_id) from category_tags where categorizable_type = 'Course')", | |
| (rdb:1) @sessions | |
| #<PagingEnumerator:0x7fd2910e0770 @callback=#<Proc:0x00007fd292ad1e18@/var/www/rails/rollbook/releases/20090702165857/vendor/plugins/paginating_find/lib/paginating_find.rb:82>, @last_page=1, @page_count=1, @auto=false, @first_page=1, @page_size=50, @page=1, @stop_page=1, @size=1> | |
| (rdb:1) @sessions | |
| #<PagingEnumerator:0x7fd2910e0770 @callback=#<Proc:0x00007fd292ad1e18@/var/www/rails/rollbook/releases/20090702165857/vendor/plugins/paginating_find/lib/paginating_find.rb:82>, @last_page=1, @page_count=1, @auto=false, @first_page=1, @page_size=50, @page=1, @stop_page=1, @size=1> | |
| (rdb:1) @sessions | |
| #<PagingEnumerator:0x7fd2910e0770 @callback=#<Proc:0x00007fd292ad1e18@/var/www/rails/rollbook/releases/20090702165857/vendor/plugins/paginating_find/lib/paginating_find.rb:82>, @last_page=1, @page_count=1, @auto=false, @first_page=1, @page_size=50, @page=1, @stop_page=1, @size=1> | |
| (rdb:1) @sessions.each {|r| p r} | |
| ActiveRecord::StatementInvalid Exception: PGError: ERROR: missing FROM-clause entry for table "courses" | |
| LINE 1: ...e = 'Course' and category_tags.categorizable_id = courses.id... | |
| ^ | |
| : SELECT "course_sessions".* FROM "course_sessions" join category_tags on category_tags.categorizable_type = 'Course' and category_tags.categorizable_id = courses.id WHERE ("course_sessions".account_id = 46 AND (course_sessions.is_active = 't' and course_sessions.in_catalog = 't' and courses.in_catalog = 't' and course_sessions.is_restricted = 'f' and course_sessions.start_on >= '2009-07-02 00:00:00.000000' and category_tags.category_id = E'241')) ORDER BY course_sessions.start_on LIMIT 1 OFFSET 0 | |
| (rdb:1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment