[UPDATE] Use 24h range for account based graphs
This commit is contained in:
parent
26802fdbb9
commit
4dcd98df21
@ -704,12 +704,13 @@ class Statistics extends Base {
|
|||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
timestamp,
|
timestamp,
|
||||||
FROM_UNIXTIME(timestamp, '%Y-%m-%d %T') AS time,
|
FROM_UNIXTIME(timestamp, '%Y-%m-%d %H:%i') AS time,
|
||||||
hashrate
|
AVG(hashrate) AS hashrate
|
||||||
FROM " . $this->getUserStatsTableName() . "
|
FROM " . $this->getUserStatsTableName() . "
|
||||||
WHERE
|
WHERE FROM_UNIXTIME(timestamp) >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||||
account_id = ?");
|
AND account_id = ?
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) {
|
GROUP BY HOUR(FROM_UNIXTIME(timestamp))");
|
||||||
|
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id ) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||||
$aData = $result->fetch_all(MYSQLI_ASSOC);
|
$aData = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
if ($format == 'json') $aData = json_encode($aData);
|
if ($format == 'json') $aData = json_encode($aData);
|
||||||
return $this->memcache->setCache(__FUNCTION__ . $account_id . $format, $aData);
|
return $this->memcache->setCache(__FUNCTION__ . $account_id . $format, $aData);
|
||||||
@ -729,11 +730,14 @@ class Statistics extends Base {
|
|||||||
SELECT
|
SELECT
|
||||||
timestamp,
|
timestamp,
|
||||||
FROM_UNIXTIME(timestamp, '%Y-%m-%d %T') AS time,
|
FROM_UNIXTIME(timestamp, '%Y-%m-%d %T') AS time,
|
||||||
SUM(hashrate) AS hashrate
|
SUM(DISTINCT account_id)
|
||||||
FROM " . $this->getUserStatsTableName() . "
|
FROM " . $this->getUserStatsTableName() . "
|
||||||
GROUP BY timestamp");
|
WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||||
|
GROUP BY HOUR(FROM_UNIXTIME(timestamp))");
|
||||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) {
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||||
|
// return json_encode(array(time() * 1000, 1000));
|
||||||
$aData = $result->fetch_all(MYSQLI_ASSOC);
|
$aData = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
var_dump($aData);
|
||||||
if ($format == 'json') $aData = json_encode($aData);
|
if ($format == 'json') $aData = json_encode($aData);
|
||||||
return $this->memcache->setCache(__FUNCTION__ . $format, $aData);
|
return $this->memcache->setCache(__FUNCTION__ . $format, $aData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user