Was wondering what a good approach would be to route leads in a round robin fashion.
I have products for sale in particular cities and each city can have multiple salespeople. How would I go about routing leads between them in an organized fashion?
The approach I can think of, not sure how efficient it is, however:
One method I can think of would be storing the salesperson id in a field in MySQL in the 'cities' table of the salesperson who last got a lead in that city. Then I could randomly assign the next lead to an agent other than the one stored in the DB (if multiple salespeople are in the particular city).
Would that be a good way to do it or is there a better way I could go about it rather than random assignment and more toward a 'round robin' approach?
Random could really come back and bite you in this kind of system. Lead distribution is *very* important to salespeople. Like, lawsuit important.
I would recommend doing it like this:
1. Determine which salespeople are eligible to receive the lead. 2. Get the timestamp of the most recent lead that was assigned to each of those salespeople. 3. Assign the lead to the salesperson who has gone the longest without receiving a lead.
This should be efficient to query the database and an effective and fair way to distribute the leads in a way that will make sense to the users.