This is the bare bones method I wrote based on a flowchart.
def insights
if signed_in?
if user.slab == 1
if user.current_activity.challenge.number_of_steps == 80000
if day_of_challenge < 31 && activity_data < 5
message = 0
end
if day_of_challenge < 31 && activity_data >= 5 && percent_completion < 50
message = 0
end
if day_of_challenge < 31 && activity_data >= 5 && percent_completion > 50 && percent_completion < 80
message = 0
end
if day_of_challenge < 31 && activity_data >= 5 && percent_completion > 80 && percent_completion < 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 5 && percent_completion > 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 10 && percent_completion < 50
message = 0
end
if day_of_challenge < 31 && activity_data >= 10 && percent_completion > 50 && percent_completion < 80
message = 0
end
if day_of_challenge < 31 && activity_data >= 10 && percent_completion > 80 && percent_completion < 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 10 && percent_completion > 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 15 && percent_completion < 50
message = 0
end
if day_of_challenge < 31 && activity_data >= 15 && percent_completion > 50 && percent_completion < 80
message = 0
end
if day_of_challenge < 31 && activity_data >= 15 && percent_completion > 80 && percent_completion < 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 15 && percent_completion > 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 20 && percent_completion < 50
message = 0
end
if day_of_challenge < 31 && activity_data >= 20 && percent_completion > 50 && percent_completion < 80
message = 0
end
if day_of_challenge < 31 && activity_data >= 20 && percent_completion > 80 && percent_completion < 100
message = 0
end
if day_of_challenge < 31 && activity_data >= 20 && percent_completion > 100
message = 0
end
if day_of_challenge > 29 && percent_completion < 50
message = 0
end
if day_of_challenge > 29 && percent_completion > 50 && percent_completion < 80
message = 0
end
if day_of_challenge > 29 && percent_completion > 80 && percent_completion < 100
message = 0
end
if day_of_challenge > 29 && percent_completion > 100
message = 0
end
end
end
end
And this might have hundreds of if conditions. What is the best way to deal with this situation?
Thanks