Last active
August 29, 2015 14:21
-
-
Save psndcsrv/ca51710ccb13d7277b4f to your computer and use it in GitHub Desktop.
Portal Teacher info
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
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