Skip to content

Instantly share code, notes, and snippets.

@samuels410
Last active February 8, 2018 09:16
Show Gist options
  • Save samuels410/cc591e16877d3df0c19d70565e7db3bb to your computer and use it in GitHub Desktop.
Save samuels410/cc591e16877d3df0c19d70565e7db3bb to your computer and use it in GitHub Desktop.
canvas lms sub account wise logged in user count
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
logins = Pseudonym.where("last_request_at > ? and last_request_at < ? and current_login_at IS NOT NULL", DateTime.yesterday.beginning_of_day,DateTime.yesterday.end_of_day)
account_pseudonyms = {}
logins.each do |pseudonym|
course=pseudonym.user.courses.first
if course
course_account_id = course.account_id
unless account_pseudonyms[course_account_id]
account_pseudonyms[course_account_id] = []
end
account_pseudonyms[course_account_id] << pseudonym
end
end
puts "Total login count is: #{logins.size}"
account_pseudonyms.each do |k,v|
puts "#{Account.find(k).name},size: #{v.size}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment