I have a system which receives leads (they are piped in via email) and then reformats the leads (capitalises postcodes etc), logs the data in the database and then emails out the lead to a third party.
Now I have another third party coming on board and they want to take leads. I wish to code the system so that it distributes the leads evenly between x (in this case 2) parties throughout the day. One of the parties wants 10 leads per day and the other will have the remainder. I do not want to simply give the first 10 leads to person A and then the rest to the other person. I need to distribute the leads evenly throughout the day. The quality of the leads varies and the time of the day is a factor in determining that quality, hence the desire to distribute evenly throughout day.
I’m trying to think of an algorithm which can help determine who gets the next lead. Obviously all the ‘counts’ can be stored in the database and that can be used to check who has received what and how many etc. Just struggling with coming up with a tidy way of coding this?
I’m expecting approx 50-60 leads per day, however this can vary day to day. Also moving forward the average could increase to 80-90. The person that gets 10 initially will take more eventually and the balance of proportions between person A & B will shift. I will have a setting in the system for recording how many person A wants. Person B will always get the overflow (whilst an overflow exists).
Can anyone help with this? I code in php.
If you don’t want to just allocate the first 10 to A, and then the remainder to B, then you’ll need to know what your expected lead count is per day. Let us imagine that you get 15 leads per day on average; then you could send two to A, and then 1 to B, on a round-robin basis.
If you get closer to the end of the day, and A only has 8 leads (i.e. your lead count is likely to be lower for the day) you could send any new leads to A regardless of whose turn it is. Or, maybe you could arrange it so that if A ends up with 9 at the end of day 1, then you’ll tweak the algorithm the next day to give them 11 at the end of day 2.
Obviously we cannot know enough about your system to give you a definitive algorithm, but that should give you some food for thought. The critical questions are: whether the 10 leads are the bulk of your leads for the day, or just a small fraction; and whether it would be acceptable to deliver an average of 10 leads/day to party A.