function ab_values($metric, $from, $to)
{
    global $r;
    //convert to unicode times
    $ut_from = strtotime($from);
    $ut_to = strtotime($to);
    //calculate difference
    $ut_diff = $ut_to - $ut_from;
    $ut_diff_in_days = $ut_diff / 24 / 60 / 60;
    //i am adding an extra day just to fix the bug.
    //this whole function needs to be rewritten with proper math
    $ut_diff_in_days += 1;
    //if ($ut_diff_in_days > 90) $ut_diff_in_days = 90;
    if ($ut_diff_in_days < 1) {
        $ut_diff_in_days = 0;
    }
    $keys = array();
    $dates = array();
    $i = 0;
    while ($i <= $ut_diff_in_days) {
        $date_key = date("m-d-y", $ut_from + $i * 24 * 60 * 60);
        $dates[] = $ut_from + $i * 24 * 60 * 60;
        $keys[] = ab_key(array("metric", $metric, $date_key));
        //add one day. this algorithm doesn't handle daylight savings time, etc. properly
        $i++;
    }
    //print_r($keys);
    $vals = $r->mget($keys);
    //print_r($vals);
    //print_r ($vals);
    $result = array();
    $i = 0;
    foreach ($vals as $val) {
        //echo $dates[$i] . " - ";
        //$d = strtotime($dates[$i]);
        //echo $d;
        $result[] = array($dates[$i], (int) $val);
        $i++;
    }
    //print_r($r);
    return $result;
}
/**
 * For the given test, return which alternative is currently forced.
 * 
 * Return null if 
 * 
 * @param $test -- name of test as string
 * @return String: name of alternative as string. null if no alternative
 * is currently forced
 */
function ab_tests_get_forced_alternative($test)
{
    global $r;
    $key = ab_key(array('test', $test, 'force'));
    $return = $r->get($key);
    return $return;
}