diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index bae7ed81..b8d3c4b3 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -369,17 +369,21 @@ class Statistics extends Base { a.no_fees as no_fees, a.username AS username, a.donate_percent AS donate_percent, - a.email AS email, - ROUND(IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS shares + a.email AS email FROM " . $this->user->getTableName() . " AS a - LEFT JOIN " . $this->share->getTableName() . " AS s - ON a.username = SUBSTRING_INDEX( s.username, '.', 1 ) WHERE a.username LIKE ? GROUP BY username ORDER BY username"); - if ($this->checkStmt($stmt) && $stmt->bind_param('s', $filter) && $stmt->execute() && $result = $stmt->get_result()) - return $this->memcache->setCache(__FUNCTION__ . $filter, $result->fetch_all(MYSQLI_ASSOC)); + if ($this->checkStmt($stmt) && $stmt->bind_param('s', $filter) && $stmt->execute() && $result = $stmt->get_result()) { + // Add our cached shares to the users + while ($row = $result->fetch_assoc()) { + $row['shares'] = $this->getUserShares($row['id']); + $aUsers[] = $row; + } + // Also cache this + return $this->memcache->setCache(__FUNCTION__ . $filter, $aUsers); + } return $this->sqlError(); } diff --git a/public/include/pages/admin/user.inc.php b/public/include/pages/admin/user.inc.php index bc562bbf..5ad323d5 100644 --- a/public/include/pages/admin/user.inc.php +++ b/public/include/pages/admin/user.inc.php @@ -31,23 +31,11 @@ if (@$_POST['query']) { $aUsers = $statistics->getAllUserStats($_POST['query']); // Add additional stats to each user - // This is not optimized yet, best is a proper SQL - // Query against the stats table? Currently cached though. foreach ($aUsers as $iKey => $aUser) { $aBalance = $transaction->getBalance($aUser['id']); $aUser['balance'] = $aBalance['confirmed']; $aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']); - if ($aUser['shares'] > 0) { - $aUser['payout']['est_block'] = round(( (int)$aUser['shares'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3); - $aUser['payout']['est_fee'] = round(($config['fees'] / 100) * $aUser['payout']['est_block'], 3); - $aUser['payout']['est_donation'] = round((( $aUser['donate_percent'] / 100) * ($aUser['payout']['est_block'] - $aUser['payout']['est_fee'])), 3); - $aUser['payout']['est_payout'] = round($aUser['payout']['est_block'] - $aUser['payout']['est_donation'] - $aUser['payout']['est_fee'], 3); - } else { - $aUser['payout']['est_block'] = 0; - $aUser['payout']['est_fee'] = 0; - $aUser['payout']['est_donation'] = 0; - $aUser['payout']['est_payout'] = 0; - } + $aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']); $aUsers[$iKey] = $aUser; } // Assign our variables diff --git a/public/templates/mmcFE/admin/user/default.tpl b/public/templates/mmcFE/admin/user/default.tpl index f8957d83..3acc8f2e 100644 --- a/public/templates/mmcFE/admin/user/default.tpl +++ b/public/templates/mmcFE/admin/user/default.tpl @@ -58,10 +58,10 @@