Merge branch 'master' into 1979-workbench-ui
[arvados.git] / apps / admin / list-inactive-users.rb
1 #!/usr/bin/env ruby
2
3 # usage: list-inactive-users.rb [n-days-old-to-ignore]
4 #
5 # (default = 7)
6
7 abort 'Error: Ruby >= 1.9.3 required.' if RUBY_VERSION < '1.9.3'
8
9 threshold = ARGV.shift.to_i rescue 7
10
11 require 'arvados'
12 arv = Arvados.new(api_version: 'v1')
13
14 saidheader = false
15 arv.user.list(where: {is_active: false})[:items].each do |user|
16   if Time.now - Time.parse(user[:created_at]) < threshold*86400
17     if !saidheader
18       saidheader = true
19       puts "Inactive users who first logged in <#{threshold} days ago:"
20       puts ""
21     end
22     puts "#{user[:modified_at]} #{user[:uuid]} #{user[:full_name]} <#{user[:email]}>"
23   end
24 end