Created
July 25, 2014 09:12
-
-
Save pjurczynski/9d2809c87d2693ebc90f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def count_customers(customer_id, order_count, totals, repeat_customers, new_customers, newly_promising_customers, newly_loyal_customers) | |
total_orders = totals.fetch(customer_id, 0) | |
if total_orders == 1 || order_count == total_orders | |
new_customers += 1 | |
elsif total_orders == 2 | |
newly_promising_customers += 1 | |
elsif (total_orders - order_count) < 4 | |
newly_loyal_customers += 1 | |
elsif order_count != total_orders | |
repeat_customers += 1 | |
end | |
[repeat_customers, new_customers, newly_promising_customers, newly_loyal_customers] | |
end |
This file contains hidden or 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
def count_customers(customer_id, order_count, totals, repeat_customers, new_customers, newly_promising_customers, newly_loyal_customers) | |
total_orders = totals.fetch(customer_id, 0) | |
if total_orders == 1 | |
new_customers += 1 | |
else | |
if total_orders > 3 | |
newly_loyal_customers += 1 if (total_orders - order_count) < 4 | |
else | |
newly_promising_customers += 1 | |
end | |
order_count == total_orders ? new_customers += 1 : repeat_customers += 1 | |
end | |
[repeat_customers, new_customers, newly_promising_customers, newly_loyal_customers] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment