/** * Calculate at given day * @param int $time timestamp */ public function calculateAt($time) { $time = mktime(23, 59, 59, date('m', $time), date('d', $time), date('Y', $time)); $data = $this->PDO->query('SELECT SUM(' . self::mysqlVDOTsumTime($this->Configuration->useElevationCorrection()) . ') as `ssum`, SUM(' . self::mysqlVDOTsum($this->Configuration->useElevationCorrection()) . ') as `value` FROM `' . PREFIX . 'training` WHERE `sportid`=' . (int) $this->RunningID . ' AND `time` BETWEEN ' . ($time - $this->Configuration->days() * DAY_IN_S) . ' AND ' . $time . ' AND `accountid`=' . (int) $this->AccountID . ' GROUP BY `sportid` LIMIT 1')->fetch(); if ($data !== false && $data['ssum'] > 0) { $this->Value = round($data['value'] / $data['ssum'], 5); } else { $this->Value = 0; } }
public function __construct($vdotDays = 30, $elevationCorrector = false) { parent::__construct(); $this->object('VDOT_DAYS')->set($vdotDays); $this->object('VDOT_USE_CORRECTION_FOR_ELEVATION')->set($elevationCorrector); }