bin/vault-usage in vault-usage-client-0.0.1 vs bin/vault-usage in vault-usage-client-0.0.4
- old
+ new
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
+require 'ostruct'
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'vault-usage-client'
@@ -10,17 +11,17 @@
start_time = Time.utc(*ARGV[1].split('-'))
stop_time = Time.utc(*ARGV[2].split('-'))
client = Vault::Usage::Client.new
-all_events = client.usage_for_user(user_hid, start_time, stop_time, ['platform:dyno:physical'])[:events]
+all_events = client.usage_for_user(user_hid, start_time, stop_time,
+ ['platform:dyno:physical'])
all_events.group_by { |e| e[:consumer] }.each do |consumer, app_events|
puts "=== #{consumer} ===".blue
app_events.group_by { |e| e[:product] }.each do |product, product_events|
-
puts " #{product}"
product_events.
map { |event| OpenStruct.new(event) }.
sort_by(&:start_time).
each do |e|
@@ -29,9 +30,8 @@
if e.start_time > e.stop_time
puts " ERROR: start_time is after stop_time".red
end
puts
end
-
end
puts
end