[FIX] Do not parse non-existing cache data, use SQL

This commit is contained in:
Sebastian Grewe 2013-10-23 07:55:17 +02:00
parent acfa8f246e
commit 1c5b53452a

View File

@ -395,23 +395,24 @@ class Statistics {
switch ($type) { switch ($type) {
case 'shares': case 'shares':
if ($data = $this->memcache->get(STATISTICS_ALL_USER_SHARES)) { if ($data = $this->memcache->get(STATISTICS_ALL_USER_SHARES)) {
// Use global cache to build data // Use global cache to build data, if we have any data there
$max = 0; if (!empty($data['data']) && is_array($data['data'])) {
foreach($data['data'] as $key => $aUser) { foreach($data['data'] as $key => $aUser) {
$shares[$key] = $aUser['valid']; $shares[$key] = $aUser['valid'];
$username[$key] = $aUser['username']; $username[$key] = $aUser['username'];
}
array_multisort($shares, SORT_DESC, $username, SORT_ASC, $data['data']);
$count = 0;
foreach ($data['data'] as $key => $aUser) {
if ($count == $limit) break;
$count++;
$data_new[$key]['shares'] = $aUser['valid'];
$data_new[$key]['account'] = $aUser['username'];
$data_new[$key]['donate_percent'] = $aUser['donate_percent'];
$data_new[$key]['is_anonymous'] = $aUser['is_anonymous'];
}
return $data_new;
} }
array_multisort($shares, SORT_DESC, $username, SORT_ASC, $data['data']);
$count = 0;
foreach ($data['data'] as $key => $aUser) {
if ($count == $limit) break;
$count++;
$data_new[$key]['shares'] = $aUser['valid'];
$data_new[$key]['account'] = $aUser['username'];
$data_new[$key]['donate_percent'] = $aUser['donate_percent'];
$data_new[$key]['is_anonymous'] = $aUser['is_anonymous'];
}
return $data_new;
} }
// No cached data, fallback to SQL and cache in local cache // No cached data, fallback to SQL and cache in local cache
$stmt = $this->mysqli->prepare(" $stmt = $this->mysqli->prepare("