Skip to content

Instantly share code, notes, and snippets.

@grahamb
Created May 8, 2013 22:02
Show Gist options
  • Select an option

  • Save grahamb/5544014 to your computer and use it in GitHub Desktop.

Select an option

Save grahamb/5544014 to your computer and use it in GitHub Desktop.
Enrollment.count(
:select => "enrollments.course_id || ':' || enrollments.user_id",
:distinct => true,
:joins => :course,
:group => "enrollments.type",
:conditions => ["
enrollments.course_id = courses.id AND
enrollments.root_account_id = 2 AND
courses.enrollment_term_id = 5 AND
enrollments.role_name IS NULL AND
enrollments.workflow_state != 'deleted' AND
courses.sis_source_id IS NOT NULL
"]
)
# results
{"DesignerEnrollment"=>146, "ObserverEnrollment"=>7, "StudentEnrollment"=>6964, "StudentViewEnrollment"=>55, "TaEnrollment"=>63, "TeacherEnrollment"=>291}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment