Skip to content

Instantly share code, notes, and snippets.

@psndcsrv
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psndcsrv/ca51710ccb13d7277b4f to your computer and use it in GitHub Desktop.
Save psndcsrv/ca51710ccb13d7277b4f to your computer and use it in GitHub Desktop.
Portal Teacher info
require 'csv'
csv = CSV.open("teachers4.csv","w")
ts = Portal::Teacher.includes(:user).all
data = ts.map do |t|
students = 0
[
t.first_name,
t.last_name,
t.email,
t.created_at,
t.user.current_sign_in_at,
(t.school.district.name rescue ""),
(t.school.name rescue ""),
(t.school.state rescue ""),
t.clazzes.map {|c| students += c.students.count; c.name }.join('; '),
students
]
}
csv << ["First name","Last name","Email","Signed up","Last login","District","School","State","Classes","Total students"]
data.each {|t| csv << t }
csv.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment