I was trying to implement round robin assignment of leads to the members-users. But when ever my function is called user cycle starts again, and all the leads are assigned to the first user. How can I assign next leads to the user that was next to the previously assigned user. eg; if lead1 is assigned to U2 and claimed, then next lead2 assignment should continue from U3.
Code that I used: Rough:
def round_robin(selected_lead)
lead = selected_lead
users = %i(U1 U2 U3).cycle
while lead.status !=“Claimed” do
assigned_user=users.next
# assigned_user <= Assign lead to
# Check to wait 10 min for claimed response...
end
puts “Lead #{lead} has been assigned to #{assigned_user}
end
I was doing this in ruby language. any suggestions would be appreciated.