Time schedule algorithm : <p>I have been trying for some time solve a scheduling problem for an App that I used to work at. This problem is as follows...</p>

<p>First time the list gets populated:</p>

<ul>
<li>will look at all contacts that a user has made “Active” in the Contacts list.</li>
<li>For each, it should look at their selected contact frequency (e.g. x days, x weeks, x months.)  </li>
<li>will compare their “last contact date” with today’s date.  For any contact where the difference between these dates is greater than their assigned contact frequency, the person is a candidate to be added to the Agent list.</li>
</ul>

<p>The order of how people will appear on the Agent list should adhere to the following rules:</p>

<ul>
<li>Contacts with longest gap between last contact are higher on the list</li>
<li>Contacts marked as Favorite go to the top of the list</li>
<li>isApp users take priority</li>
</ul>

<p>From this list of “candidates”, the algorithm should then also review contact history for each. For contacts with the following assigned contact frequency, follow these rules </p>

<ul>
<li>Every x Days – Do not take history into account.  Just add when they’re past due </li>
<li>Every x Weeks – if contact already within the last 3 days, do not show, and skip to the next time they will be up for contacting.  </li>
<li>Every x Months – if contact already within the last 7 days, do not show, and skip to the next time they will be up for contacting.</li>
<li>Every x Year – if contacted in the last month, do not show, and skip to the next time they will be up for contacting.</li>
</ul>
