Last active
May 9, 2020 14:59
-
-
Save CapSens-SM/e31033488ac4ef0fe399f54eee96bf56 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
class CustomerDecorator < Draper::Decorator | |
delegate_all | |
# [ other decorator logic here ... ] | |
def state_completition_in_percent | |
customer_state_index = Customer.state.values.index(state).to_f + 1 | |
return 100 if state == :terminated | |
total_states_count_without_terminated_state = Customer.state.values.length - 1 | |
completion = customer_state_index / total_states_count_without_terminated_state | |
(completion * 100).round(0) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment