Realtme action improvements

This commit is contained in:
marcdeb1 2018-12-19 00:53:39 +01:00
parent cbee21c07c
commit dfd7af81f9
3 changed files with 7 additions and 10 deletions

View file

@ -220,19 +220,15 @@ class MainController extends AppController {
$this->loadModel('Transactions'); $this->loadModel('Transactions');
// load 10 blocks and transactions // load 10 blocks and transactions
$conn = ConnectionManager::get('default');
$blocks = $this->Blocks->find()->select(['height', 'block_time', 'transaction_hashes'])->order(['height' => 'desc'])->limit(10)->toArray(); $blocks = $this->Blocks->find()->select(['height', 'block_time', 'transaction_hashes'])->order(['height' => 'desc'])->limit(10)->toArray();
for ($i = 0; $i < count($blocks); $i++) { for ($i = 0; $i < count($blocks); $i++) {
$tx_hashes = preg_split('#,#', $blocks[$i]->transaction_hashes); $tx_hashes = preg_split('#,#', $blocks[$i]->transaction_hashes);
$blocks[$i]->transaction_count = count($tx_hashes); $blocks[$i]->transaction_count = count($tx_hashes);
} }
$stmt = $conn->execute('SELECT T.id, T.hash, T.input_count, T.output_count, IFNULL(T.transaction_time, T.created_at) AS TxTime ' . $transactions = $this->Transactions->find()->select(['id', 'hash', 'input_count', 'output_count', 'transaction_time', 'created_at'])->order(['created_at' => 'desc'])->limit(10)->toArray();
'FROM transaction T ORDER BY created_at DESC LIMIT 10');
$txs = $stmt->fetchAll(\PDO::FETCH_OBJ);
$this->set('blocks', $blocks); $this->set('blocks', $blocks);
$this->set('txs', $txs); $this->set('txs', $transactions);
} }
public function find() { public function find() {

View file

@ -59,8 +59,9 @@ $ctTag = $claim->getContentTag();
<div class="label half-width">Author</div> <div class="label half-width">Author</div>
<div class="label half-width">License</div> <div class="label half-width">License</div>
<!--
<div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div> <div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
<!--
<div class="value half-width" title="<?php echo strlen(trim($claim->license)) > 0 ? $claim->license : '' ?>"> <div class="value half-width" title="<?php echo strlen(trim($claim->license)) > 0 ? $claim->license : '' ?>">
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?> <?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?> <?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>

View file

@ -153,9 +153,9 @@
<tbody> <tbody>
<?php foreach ($txs as $tx): ?> <?php foreach ($txs as $tx): ?>
<tr data-hash="<?php echo $tx->Hash ?>" data-time="<?php echo $tx->TxTime ?>"> <tr data-hash="<?php echo $tx->Hash ?>" data-time="<?php echo $tx->transaction_time ?>">
<td class="w200"><div><a href="/tx/<?php echo $tx->Hash ?>" target="_blank"><?php echo $tx->Hash ?></a></div></td> <td class="w200"><div><a href="/tx/<?php echo $tx->hash ?>" target="_blank"><?php echo $tx->hash ?></a></div></td>
<td><?php echo \Carbon\Carbon::createFromTimestamp($tx->TxTime)->diffForHumans(); ?></td> <td><?php echo $tx->created_at->diffForHumans(); ?></td>
<td class="right"><?php echo $tx->input_count ?></td> <td class="right"><?php echo $tx->input_count ?></td>
<td class="right"><?php echo $tx->output_count ?></td> <td class="right"><?php echo $tx->output_count ?></td>
<td class="right"><?php echo number_format($tx->value(), 8, '.', '') ?> LBC</td> <td class="right"><?php echo number_format($tx->value(), 8, '.', '') ?> LBC</td>