[IMPROVED] Roundstatistics code and templates

* [IMPROVED] Removed uneeded data array from round page
* [IMRPOVED] Sorted round shares via User ID as key for easier access
* [IMPROVED] Added share count to transaction list in prop
This commit is contained in:
Sebastian Grewe 2013-10-27 09:12:34 +01:00
parent 1b53456fd6
commit b8159f06d7
5 changed files with 28 additions and 32 deletions

View File

@ -113,6 +113,7 @@ class RoundStats {
public function getRoundStatsForAccounts($iHeight=0) {
$stmt = $this->mysqli->prepare("
SELECT
a.id,
a.username,
a.is_anonymous,
s.valid,
@ -124,8 +125,12 @@ class RoundStats {
GROUP BY username ASC
ORDER BY valid DESC
");
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) {
while ($row = $result->fetch_assoc()) {
$aData[$row['id']] = $row;
}
return $aData;
}
return false;
}
@ -179,6 +184,7 @@ class RoundStats {
$stmt = $this->mysqli->prepare("
SELECT
t.id AS id,
a.id AS uid,
a.username AS username,
a.is_anonymous,
t.type AS type,

View File

@ -26,38 +26,26 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
$_REQUEST['height'] = $iHeight;
$iPPLNSShares = 0;
$aSharesData = array();
$aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iHeight);
$aRoundShareStats = $roundstats->getRoundStatsForAccounts($iHeight);
$aUserRoundTransactions = $roundstats->getAllRoundTransactions($iHeight);
if ($config['payout_system'] == 'pplns') {
$aUserRoundTransactions = $roundstats->getAllRoundTransactions($iHeight);
foreach($aRoundShareStats as $key => $aData) {
$aSharesData[$aData['username']] = $aData;
}
$aPPLNSRoundShares = $roundstats->getPPLNSRoundStatsForAccounts($iHeight);
foreach($aPPLNSRoundShares as $key => $aData) {
foreach($aPPLNSRoundShares as $aData) {
$iPPLNSShares += $aData['pplns_valid'];
}
$block_avg = $block->getAvgBlockShares($iHeight, $config['pplns']['blockavg']['blockcount']);
} else if ($config['payout_system'] == 'prop') {
$aUserRoundTransactions = $roundstats->getAllRoundTransactions($iHeight);
$smarty->assign('PPLNSROUNDSHARES', $aPPLNSRoundShares);
$smarty->assign("PPLNSSHARES", $iPPLNSShares);
$smarty->assign("BLOCKAVGCOUNT", $config['pplns']['blockavg']['blockcount']);
$smarty->assign("BLOCKAVERAGE", $block_avg );
}
// Propagate content our template
$smarty->assign('BLOCKDETAILS', $aDetailsForBlockHeight);
$smarty->assign('ROUNDSHARES', $aRoundShareStats);
if ($config['payout_system'] == 'pplns') {
$smarty->assign('SHARESDATA', $aSharesData);
$smarty->assign('PPLNSROUNDSHARES', $aPPLNSRoundShares);
$smarty->assign("PPLNSSHARES", $iPPLNSShares);
$smarty->assign("BLOCKAVGCOUNT", $config['pplns']['blockavg']['blockcount']);
$smarty->assign("BLOCKAVERAGE", $block_avg );
$smarty->assign("ROUNDTRANSACTIONS", $aUserRoundTransactions);
} else if ($config['payout_system'] == 'prop') {
$smarty->assign("ROUNDTRANSACTIONS", $aUserRoundTransactions);
}
$smarty->assign("ROUNDTRANSACTIONS", $aUserRoundTransactions);
} else {
$debug->append('Using cached page', 3);
}

View File

@ -17,11 +17,11 @@
{section txs $ROUNDTRANSACTIONS}
<tr{if $GLOBAL.userdata.username|default:"" == $ROUNDTRANSACTIONS[txs].username}{assign var=listed value=1} style="background-color:#99EB99;"{else} class="{cycle values="odd,even"}"{/if}>
<td>{if $ROUNDTRANSACTIONS[txs].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$ROUNDTRANSACTIONS[txs].username|escape}{/if}</td>
<td align="right">{$SHARESDATA[$ROUNDTRANSACTIONS[txs].username].valid|number_format}</td>
<td align="right">{if $SHARESDATA[$ROUNDTRANSACTIONS[txs].username].valid > 0 }{(( 100 / $BLOCKDETAILS.shares) * $SHARESDATA[$ROUNDTRANSACTIONS[txs].username].valid)|number_format:"2"}{else}0.00{/if}</td>
<td align="right">{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format}</td>
<td align="right">{if $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid > 0 }{(( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid)|number_format:"2"}{else}0.00{/if}</td>
<td align="right">{$PPLNSROUNDSHARES[txs].pplns_valid|number_format|default:"0"}</td>
<td align="right">{if $PPLNSROUNDSHARES[txs].pplns_valid > 0 }{(( 100 / $PPLNSSHARES) * $PPLNSROUNDSHARES[txs].pplns_valid)|number_format:"2"|default:"0"}{else}0{/if}</td>
<td align="right">{if $SHARESDATA[$ROUNDTRANSACTIONS[txs].username].valid > 0 && $PPLNSROUNDSHARES[txs].pplns_valid > 0}{math assign="percentage1" equation=(100 / ((( 100 / $BLOCKDETAILS.shares) * $SHARESDATA[$ROUNDTRANSACTIONS[txs].username].valid) / (( 100 / $PPLNSSHARES) * $PPLNSROUNDSHARES[txs].pplns_valid)))}{else if $PPLNSROUNDSHARES[txs].pplns_valid == 0}{assign var=percentage1 value=0}{else}{assign var=percentage1 value=100}{/if}
<td align="right">{if $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid > 0 && $PPLNSROUNDSHARES[txs].pplns_valid > 0}{math assign="percentage1" equation=(100 / ((( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid) / (( 100 / $PPLNSSHARES) * $PPLNSROUNDSHARES[txs].pplns_valid)))}{else if $PPLNSROUNDSHARES[txs].pplns_valid == 0}{assign var=percentage1 value=0}{else}{assign var=percentage1 value=100}{/if}
<font color="{if ($percentage1 >= 100)}green{else}red{/if}">{$percentage1|number_format:"2"}</font></b></td>
<td align="right" style="padding-right: 25px;">{$ROUNDTRANSACTIONS[txs].amount|default:"0"|number_format:"8"}</td>
{assign var=percentage1 value=0}

View File

@ -13,15 +13,15 @@
<tbody>
{assign var=rank value=1}
{assign var=listed value=0}
{section contrib $ROUNDSHARES}
<tr{if $GLOBAL.userdata.username|default:"" == $ROUNDSHARES[contrib].username}{assign var=listed value=1} style="background-color:#99EB99;"{else} class="{cycle values="odd,even"}"{/if}>
{foreach key=id item=data from=$ROUNDSHARES}
<tr{if $GLOBAL.userdata.username|default:"" == $data.username}{assign var=listed value=1} style="background-color:#99EB99;"{else} class="{cycle values="odd,even"}"{/if}>
<td align="center">{$rank++}</td>
<td>{if $ROUNDSHARES[contrib].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$ROUNDSHARES[contrib].username|escape}{/if}</td>
<td align="right">{$ROUNDSHARES[contrib].valid|number_format}</td>
<td align="right">{$ROUNDSHARES[contrib].invalid|number_format}</td>
<td align="right" style="padding-right: 25px;">{if $ROUNDSHARES[contrib].invalid > 0 }{($ROUNDSHARES[contrib].invalid / $ROUNDSHARES[contrib].valid * 100)|number_format:"2"|default:"0"}{else}0.00{/if}</td>
<td>{if $data.is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$data.username|escape}{/if}</td>
<td align="right">{$data.valid|number_format}</td>
<td align="right">{$data.invalid|number_format}</td>
<td align="right" style="padding-right: 25px;">{if $data.invalid > 0 }{($data.invalid / $data.valid * 100)|number_format:"2"|default:"0"}{else}0.00{/if}</td>
</tr>
{/section}
{/foreach}
</tbody>
</table>
</article>

View File

@ -5,6 +5,7 @@
<tr>
<th>User Name</th>
<th align="center">Type</th>
<th align="right">Round Shares</th>
<th align="right" scope="col">Round %</th>
<th align="right" style="padding-right: 25px;">Amount</th>
</tr>
@ -14,7 +15,8 @@
<tr{if $GLOBAL.userdata.username|default:"" == $ROUNDTRANSACTIONS[txs].username} style="background-color:#99EB99;"{else} class="{cycle values="odd,even"}"{/if}>
<td>{if $ROUNDTRANSACTIONS[txs].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$ROUNDTRANSACTIONS[txs].username|escape}{/if}</td>
<td align="center">{$ROUNDTRANSACTIONS[txs].type|default:""}</td>
<td align="right">{(( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[txs].valid)|default:"0"|number_format:"2"}</td>
<td align="right">{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format}</td>
<td align="right">{(( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid)|default:"0"|number_format:"2"}</td>
<td align="right" style="padding-right: 25px;">{$ROUNDTRANSACTIONS[txs].amount|default:"0"|number_format:"8"}</td>
</tr>
{/section}