[IMPROVEMENT] Support incremental contrib shares
This commit is contained in:
parent
a0fa71b264
commit
07f0361050
@ -22,11 +22,11 @@ limitations under the License.
|
|||||||
// Include all settings and classes
|
// Include all settings and classes
|
||||||
require_once('shared.inc.php');
|
require_once('shared.inc.php');
|
||||||
|
|
||||||
// Since fetching from cache is disabled, overwrite our stats
|
// Per user share statistics based on all shares submitted
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
if (!$statistics->getTopContributors('shares'))
|
if ( ! $aAllUserShares = $statistics->getAllUserShares() )
|
||||||
$log->logError("getTopContributors shares update failed");
|
$log->logError('getAllUserShares update failed');
|
||||||
$log->logInfo("getTopContributors shares " . number_format(microtime(true) - $start, 2) . " seconds");
|
$log->logInfo("getAllUserShares " . number_format(microtime(true) - $start, 2) . " seconds");
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
if (!$statistics->getTopContributors('hashes'))
|
if (!$statistics->getTopContributors('hashes'))
|
||||||
@ -38,12 +38,6 @@ if (!$statistics->getCurrentHashrate())
|
|||||||
$log->logError("getCurrentHashrate update failed");
|
$log->logError("getCurrentHashrate update failed");
|
||||||
$log->logInfo("getCurrentHashrate " . number_format(microtime(true) - $start, 2) . " seconds");
|
$log->logInfo("getCurrentHashrate " . number_format(microtime(true) - $start, 2) . " seconds");
|
||||||
|
|
||||||
// Per user share statistics based on all shares submitted
|
|
||||||
$start = microtime(true);
|
|
||||||
if ( ! $aAllUserShares = $statistics->getAllUserShares() )
|
|
||||||
$log->logError('getAllUserShares update failed');
|
|
||||||
$log->logInfo("getAllUserShares " . number_format(microtime(true) - $start, 2) . " seconds");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Admin specific statistics, we cache the global query due to slowness
|
// Admin specific statistics, we cache the global query due to slowness
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|||||||
@ -190,6 +190,8 @@ class Statistics {
|
|||||||
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
|
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
|
||||||
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid,
|
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid,
|
||||||
u.id AS id,
|
u.id AS id,
|
||||||
|
u.donate_percent AS donate_percent,
|
||||||
|
u.is_anonymous AS is_anonymous,
|
||||||
u.username AS username
|
u.username AS username
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
@ -363,6 +365,21 @@ class Statistics {
|
|||||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $type . $limit)) return $data;
|
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $type . $limit)) return $data;
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'shares':
|
case 'shares':
|
||||||
|
if ($data = $this->memcache->get(STATISTICS_ALL_USER_SHARES)) {
|
||||||
|
// Use global cache to build data
|
||||||
|
$max = 0;
|
||||||
|
foreach($data['data'] as $key => $aUser) {
|
||||||
|
$shares[$key] = $aUser['valid'];
|
||||||
|
$username[$key] = $aUser['username'];
|
||||||
|
}
|
||||||
|
array_multisort($shares, SORT_DESC, $username, SORT_ASC, $data['data']);
|
||||||
|
foreach ($data['data'] as $key => $aUser) {
|
||||||
|
$data_new[$key]['shares'] = $aUser['valid'];
|
||||||
|
$data_new[$key]['account'] = $aUser['username'];
|
||||||
|
}
|
||||||
|
return $data_new;
|
||||||
|
}
|
||||||
|
// No cached data, fallback to SQL and cache in local cache
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
a.donate_percent AS donate_percent,
|
a.donate_percent AS donate_percent,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user