/** * Get total of last 6 months * * @param Request $r * @return type * @throws InvalidDatabaseOperationException */ public static function apiCounts(Request $r) { $totals = array(); Cache::getFromCacheOrSet(Cache::RUN_COUNTS, '', $r, function (Request $r) { $totals = array(); $totals['total'] = array(); $totals['ac'] = array(); try { $date = date('Y-m-d', strtotime('1 days')); for ($i = 0; $i < 30 * 3; $i++) { $totals['total'][$date] = RunsDAO::GetRunCountsToDate($date); $totals['ac'][$date] = RunsDAO::GetAcRunCountsToDate($date); $date = date('Y-m-d', strtotime('-' . $i . ' days')); } } catch (Exception $e) { throw new InvalidDatabaseOperationException($e); } return $totals; }, $totals, 24 * 60 * 60); return $totals; }