Created
June 3, 2019 15:06
-
-
Save odayvhl/9b39b36c9cdb320c3451c0f471107885 to your computer and use it in GitHub Desktop.
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
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