Skip to content

Instantly share code, notes, and snippets.

@vsaarinen
Last active September 7, 2015 11:33
Show Gist options
  • Save vsaarinen/021b5818de234f08e30f to your computer and use it in GitHub Desktop.
Save vsaarinen/021b5818de234f08e30f to your computer and use it in GitHub Desktop.
List inactive users in a Flowdock organization
#!/usr/bin/ruby
require 'rubygems'
require 'flowdock'
ORGANIZATION_DOMAIN = 'FLOWDOCK_DOMAIN'
client = Flowdock::Client.new(api_token: 'PERSONAL_API_TOKEN')
last_login_days_ago = 90 # select users whose last login time is at a minimum this many days ago
users = client.get("/organizations/#{ORGANIZATION_DOMAIN}/audits/users")
inactive_users = users.select { |user|
user["accessed_at"] == nil || Time.parse(user["accessed_at"]) < (Time.now - (60 * 60 * 24 * last_login_days_ago))
}
puts "Inactive user emails (printed #{Time.now}):"
inactive_users.each{ |user| puts "#{user["email"]}, #{user["accessed_at"]}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment