if custom_friend is not None:
        return ([], [custom_friend])
    else:
        query = (atable.codechef_lr == current.INITIAL_DATE) & \
                (atable.codechef_handle != "") & \
                (atable.blacklisted == False) & \
                (atable.registration_key == "") # Unverified email

        users = db(query).select(orderby="<random>", limitby=(0, 5))
        return (users, [])


if __name__ == "__main__":

    retrieval_type = sys.argv[1]
    metric_handlers = utilities.init_metric_handlers(
        (retrieval_type == "daily_retrieve"))

    if retrieval_type == "new_users":
        users, custom_users = new_users()
    elif retrieval_type == "daily_retrieve":
        users, custom_users = daily_retrieve()
    elif retrieval_type == "re_retrieve":
        users, custom_users = re_retrieve()
    elif retrieval_type == "specific_users":
        users, custom_users = specific_users()
    elif retrieval_type == "refreshed_users":
        users, custom_users = refreshed_users()
    elif retrieval_type == "codechef_new_retrievals":
        users, custom_users = codechef_new_retrievals()
    else:
        print "Invalid arguments"
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
"""

import utilities
from gluon import current

metric_handlers = utilities.init_metric_handlers(log_to_redis=True)

html_body = "<html><head><title>StopStalk submission retrieval</title></head><body><h2>StopStalk Submission Retrieval Report</h2>"
for site in current.SITES:
    lower_site = site.lower()
    html_body += "<h3><u>%s</u></h3>" % site
    html_body += "<table border='1' cellpadding='4' cellspacing='0'>"
    for key in metric_handlers[lower_site]:
        html_body += metric_handlers[lower_site][key].get_html()
        metric_handlers[lower_site][key].flush_keys()
    html_body += "</table><br/>"
    html_body += "________________________________________________<br/>"

html_body += "<h3><u>Overall</u></h3>"
html_body += "<table border='1' cellpadding='4' cellspacing='0'>"
for key in metric_handlers["overall"]: