Skip to content

Instantly share code, notes, and snippets.

@odayvhl
Created June 3, 2019 15:06
Show Gist options
  • Save odayvhl/9b39b36c9cdb320c3451c0f471107885 to your computer and use it in GitHub Desktop.
Save odayvhl/9b39b36c9cdb320c3451c0f471107885 to your computer and use it in GitHub Desktop.
require 'csv'
require 'time'
CSV_FILE = ARGV[0]
CUTOFF = 2015
abandoned = []
variance = []
table = CSV.read(CSV_FILE)
table.each_with_index do |row, i|
next if i == 0
user_id = row[0]
last_request_at = row[2]
current_login_at = row[3]
if current_login_at == 'NULL' or last_request_at == 'NULL'
abandoned.push(user_id)
next
else
last_request_date = Time.parse(last_request_at)
current_login_date = Time.parse(current_login_at)
variance.push(last_request_date - current_login_date)
end
end
puts "variance #{variance.inspect}"
puts "abandoned #{abandoned.size}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment