Last active
September 7, 2015 11:33
-
-
Save vsaarinen/021b5818de234f08e30f to your computer and use it in GitHub Desktop.
List inactive users in a Flowdock organization
This file contains 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
#!/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