From ab85af19a149686825e66d3d66fc31f8f8e92ee3 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 23:23:19 +0200 Subject: [PATCH 1/4] Re-add shares archive table for 24h hashrates This should fix #312 and fix #256 where hashrates are reset on quick rounds. Users are not able to properly view their past 24h hashrates. Will be merged once confirmed working. --- public/include/classes/statistics.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 2ca5bfd1..8f530003 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -374,6 +374,16 @@ class Statistics { ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, HOUR(s.time) AS hour FROM " . $this->share->getTableName() . " AS s, accounts AS a + WHERE time < NOW() - INTERVAL 1 HOUR + AND time > NOW() - INTERVAL 25 HOUR + AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) + AND a.id = ? + GROUP BY HOUR(time) + UNION ALL + SELECT + ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, + HOUR(s.time) AS hour + FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) From 380e802c75d4bc6abc71a39445c672ca0271b2e8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 6 Jul 2013 08:34:41 +0200 Subject: [PATCH 2/4] fixing stmt issue --- public/include/classes/statistics.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 8f530003..42ef3019 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -389,7 +389,7 @@ class Statistics { AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND a.id = ? GROUP BY HOUR(time)"); - if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) { + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result()) { $aData = array(); while ($row = $result->fetch_assoc()) { $aData[$row['hour']] = $row['hashrate']; From 89af793a28248a727ba2d1186376c450aed3249d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 6 Jul 2013 17:32:58 +0200 Subject: [PATCH 3/4] Fixing pool hashrate graph Should fix #312 completely. --- public/include/classes/statistics.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 42ef3019..41fd7d95 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -410,6 +410,14 @@ class Statistics { $this->debug->append("STA " . __METHOD__, 4); if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" + SELECT + IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000), 0) AS hashrate, + HOUR(s.time) AS hour + FROM " . $this->share->getTableName() . " AS s + WHERE time < NOW() - INTERVAL 1 HOUR + AND time > NOW() - INTERVAL 25 HOUR + GROUP BY HOUR(time) + UNION ALL SELECT IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000), 0) AS hashrate, HOUR(s.time) AS hour From 9d50c9a2229a7e5d58a9b3111a8b5b7f9af46a39 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 7 Jul 2013 19:39:16 +0200 Subject: [PATCH 4/4] User proper archive table for union Addresses #312 --- public/include/classes/statistics.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 41fd7d95..3e375249 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -421,7 +421,7 @@ class Statistics { SELECT IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000), 0) AS hashrate, HOUR(s.time) AS hour - FROM " . $this->share->getTableName() . " AS s + FROM " . $this->share->getArchiveTableName() . " AS s WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR GROUP BY HOUR(time)");