Commit a3480c78 authored by Kalinka's avatar Kalinka
Browse files

Command/CronMultiOutCommand.php:

  - update caches on run
Controller/TransactionController.php:
  - show all Transactions
templates/:
  - Fix display stuff
wallet_additions.sql:
  - add cache update procedure
parent f4923b4c
......@@ -44,6 +44,8 @@ class CronMultiOutCommand extends Command
FROM transaction t
WHERE t.type = 0 AND t.subtype = 1 AND t.db_id IN (?) AND attachment_bytes IS NOT NULL';
const updateCaches = 'CALL cache_all();';
protected static $defaultName = 'explorer:cron:multiout';
/** @var Connection $connection*/
......@@ -113,6 +115,13 @@ class CronMultiOutCommand extends Command
$this->debug('=============================');
}
$this->debug('=============================');
$this->debug('Updating Caches:');
$this->debug('=============================');
$this->debug('=============================');
$caches = $this->connection->prepare(self::updateCaches);
$caches->execute();
$this->debug('=============================');
}
/**
......
......@@ -117,6 +117,7 @@ class BlockController extends AbstractController
*/
public function blockDetails($block_id) {
$con = $this->entityManager->getConnection();
// TODO: Fix TX Count!!
$stmt = $con->prepare(self::BlockDetails);
$stmt->bindValue(1, $block_id);
$stmt->execute();
......
......@@ -44,11 +44,12 @@ class TransactionController extends AbstractController
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type
FROM mosr
LEFT JOIN mos ON (mos.db_id = mosr.db_id)
JOIN mos ON (mos.db_id = mosr.db_id)
JOIN transaction t ON (mosr.db_id = t.db_id AND t.height = ?)
) as x
LEFT JOIN account s ON (x.sender_id = s.id AND s.latest = 1)
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1) -- TransactionController/TransactionsByHeight";
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1)
WHERE x.recipient_id IS NOT NULL -- TransactionController/TransactionsByHeight";
const TransactionsByBlockId = " SELECT x.id, x.sender_id, x.recipient_id, x.fee, x.amount, x.unixtime,
......@@ -62,7 +63,7 @@ class TransactionController extends AbstractController
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type
FROM transaction t
JOIN block b ON (t.height = b.height AND CAST(b.id AS UNSIGNED) = ?)
WHERE CAST(t.block_id AS UNSIGNED) = ?
UNION
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
......@@ -72,8 +73,7 @@ class TransactionController extends AbstractController
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type
FROM mo
LEFT JOIN transaction t ON (mo.db_id = t.db_id)
JOIN block b ON (t.height = b.height AND CAST(b.id AS UNSIGNED) = ?)
JOIN transaction t ON (mo.db_id = t.db_id AND CAST(t.block_id AS UNSIGNED) = ?)
UNION
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
......@@ -83,16 +83,30 @@ class TransactionController extends AbstractController
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type
FROM mosr
LEFT JOIN mos ON (mos.db_id = mosr.db_id)
LEFT JOIN transaction t ON (mosr.db_id = t.db_id)
JOIN block b ON (t.height = b.height AND CAST(b.id AS UNSIGNED) = ?)
JOIN mos ON (mos.db_id = mosr.db_id)
JOIN transaction t ON (mosr.db_id = t.db_id AND CAST(t.block_id AS UNSIGNED) = ?)
) as x
LEFT JOIN account s ON (x.sender_id = s.id AND s.latest = 1)
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1) -- TransactionController/TransactionsByBlockId";
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1)
WHERE x.recipient_id IS NOT NULL -- TransactionController/TransactionsByBlockId";
const TransactionCountByAccountId = "
SELECT SUM(count) AS count FROM (
-- One To One
SELECT count(t.id) AS count FROM transaction t WHERE (CAST(t.sender_id AS UNSIGNED) = ? OR CAST(t.recipient_id AS UNSIGNED) = ?) AND t.type = 0 AND t.subtype = 0 AND t.recipient_id IS NOT NULL
UNION -- MultiOut IN
SELECT count(mo.recipient_id) AS count FROM mo LEFT JOIN transaction t ON (mo.db_id = t.db_id) WHERE CAST(mo.recipient_id AS UNSIGNED) = ?
UNION -- MultiOut OUT
SELECT count(mo.recipient_id) AS count FROM transaction t JOIN mo ON (t.db_id = mo.db_id) WHERE CAST(t.sender_id AS UNSIGNED) = ? AND t.type = 0 AND t.subtype = 1
UNION -- MultiOutSame IN
SELECT count(mosr.recipient_id) AS count FROM mosr LEFT JOIN transaction t ON (mosr.db_id = t.db_id AND t.type = 0 AND t.subtype = 2) WHERE CAST(mosr.recipient_id AS UNSIGNED) = ?
UNION -- MultiOutSame OUT
SELECT count(mosr.recipient_id) AS count FROM transaction t LEFT JOIN mosr ON (mosr.db_id = t.db_id AND t.type = 0 AND t.subtype = 2) WHERE CAST(t.sender_id AS UNSIGNED) = ?
) as x";
const TransactionByAccountId = "SELECT x.id, x.sender_id, x.recipient_id, x.fee, x.amount, x.unixtime,
x.transaction_type, x.block_id, x.height, s.name AS sender_name, r.name as recipient_name
FROM (
FROM ( -- One to One transactions, Pool: 7,8s,
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
CAST(t.recipient_id AS UNSIGNED) AS recipient_id,
......@@ -103,8 +117,9 @@ class TransactionController extends AbstractController
CAST(t.block_id AS UNSIGNED) as block_id,
t.height
FROM transaction t
WHERE CAST(t.sender_id AS UNSIGNED) = ? OR CAST(t.recipient_id AS UNSIGNED) = ?
UNION
WHERE (CAST(t.sender_id AS UNSIGNED) = ? OR CAST(t.recipient_id AS UNSIGNED) = ?)
AND t.type = 0 AND t.subtype = 0 AND t.recipient_id IS NOT NULL
UNION -- Incoming MultiOut Transactions, Pool 0,2s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
CAST(mo.recipient_id AS UNSIGNED) AS recipient_id,
......@@ -115,9 +130,22 @@ class TransactionController extends AbstractController
CAST(t.block_id AS UNSIGNED) as block_id,
t.height
FROM mo
LEFT JOIN transaction t ON (mo.db_id = t.db_id)
LEFT JOIN transaction t ON (mo.db_id = t.db_id AND t.type = 0 AND t.subtype = 1)
WHERE CAST(mo.recipient_id AS UNSIGNED) = ?
UNION
UNION -- Outgoing MultiOut Transactions, Pool 0,0s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
CAST(mo.recipient_id AS UNSIGNED) AS recipient_id,
FORMAT(t.fee / 100000000, 2) AS fee,
FORMAT(t.amount / 100000000, 2) AS amount,
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type,
CAST(t.block_id AS UNSIGNED) as block_id,
t.height
FROM transaction t
JOIN mo ON (t.db_id = mo.db_id)
WHERE CAST(t.sender_id AS UNSIGNED) = ? AND t.type = 0 AND t.subtype = 1
UNION -- Incoming MultiOutSame Transactions, Pool 0,2s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
CAST(mosr.recipient_id AS UNSIGNED) AS recipient_id,
......@@ -129,15 +157,29 @@ class TransactionController extends AbstractController
t.height
FROM mosr
LEFT JOIN mos ON (mosr.db_id = mos.db_id)
LEFT JOIN transaction t ON (mosr.db_id = t.db_id)
LEFT JOIN transaction t ON (mosr.db_id = t.db_id AND t.type = 0 AND t.subtype = 2)
WHERE CAST(mosr.recipient_id AS UNSIGNED) = ?
UNION -- Outgoing MultiOutSame Transactions, Pool 3,1s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
CAST(mosr.recipient_id AS UNSIGNED) AS recipient_id,
FORMAT(t.fee / 100000000, 2) AS fee,
FORMAT(t.amount / mos.recipient_count / 100000000, 2) AS amount,
t.timestamp + 1407722400 AS unixtime,
getTransactionType(t.type, t.subtype) as transaction_type,
CAST(t.block_id AS UNSIGNED) as block_id,
t.height
FROM transaction t
LEFT JOIN mos ON (mos.db_id = t.db_id)
LEFT JOIN mosr ON (mosr.db_id = t.db_id)
WHERE CAST(t.sender_id AS UNSIGNED) = ? AND t.type = 0 AND t.subtype = 2
) as x
LEFT JOIN account s ON (x.sender_id = s.id AND s.latest = 1)
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1)
LEFT JOIN ec_account s ON (x.sender_id = s.id)
LEFT JOIN ec_account r ON (x.recipient_id = r.id)
WHERE x.recipient_id IS NOT NULL
ORDER BY x.unixtime DESC -- TransactionController/TransactionsByAccountId";
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
......@@ -226,10 +268,12 @@ class TransactionController extends AbstractController
$con = $this->entityManager->getConnection();
$stmt = $con->prepare(self::TransactionByAccountId);
$stmt->bindValue(1, $id);
$stmt->bindValue(2, $id);
$stmt->bindValue(3, $id);
$stmt->bindValue(4, $id);
$stmt->bindValue(1, $id, ParameterType::INTEGER);
$stmt->bindValue(2, $id, ParameterType::INTEGER);
$stmt->bindValue(3, $id, ParameterType::INTEGER);
$stmt->bindValue(4, $id, ParameterType::INTEGER);
$stmt->bindValue(5, $id, ParameterType::INTEGER);
$stmt->bindValue(6, $id, ParameterType::INTEGER);
$stmt->execute();
$transactions = $stmt->fetchAll();
......
......@@ -37,8 +37,8 @@
<div class="col-md-3"></div>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="col-md-1"></div>
<div class="col-md-10">
<ul class="nav nav-tabs" id="accountTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="tx-tab" data-toggle="tab" href="#tx" role="tab" aria-controls="tx" aria-selected="true">Transactions ({{ (account.count_sent + account.tx_count + account.mo_count + account.mos_count) }})</a>
......@@ -54,6 +54,6 @@
<div class="tab-pane fade" id="asset" role="tabpanel" aria-labelledby="asset-tab">Asset, to be done</div>
</div>
</div>
<div class="col-md-2"></div>
<div class="col-md-1"></div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -56,24 +56,24 @@
<tr>
<td><a href="#">{{ transaction.id }}</a></td>
<td>{{ transaction.transaction_type }}</td>
<td>
<td style="text-align: center">
<a href="{{ path('account_details', {id: transaction.sender_id | toAccountId }) }}">
{{ transaction.sender_id | toRSAddress }}<br />{{ transaction.sender_name }}
</a>
</td>
<td>
<td style="text-align: center">
{% if transaction.recipient_id is not null %}
<a href="{{ path('account_details', {id: transaction.recipient_id | toAccountId }) }}">
{{ transaction.recipient_id | toRSAddress }}<br />{{ transaction.recipient_name }}
</a>
{% else%}
{% else %}
Multiple Recipients, <a href="#">Details</a>
{% endif %}
</td>
<td>{{ transaction.amount }}</td>
<td>{{ transaction.fee }}</td>
{% if route != "transactions_by_height" and route != "transactions_by_blockId" %}
<td><a href="{{ url('block_details', {'block_id': transaction.block_id}) }}">{{ transaction.height }}</a></td>
<td><a href="{{ url('block_details', {'block_id': transaction.block_id}) }}">#{{ transaction.height }}</a></td>
{% endif %}
<td>{{ transaction.unixtime | date ("Y-m-d H:i:s", "Europe/Berlin") }}</td>
</tr>
......
......@@ -68,6 +68,15 @@ DELIMITER ;
DELIMITER $$
CREATE PROCEDURE cache_all()
BEGIN
DROP TABLE IF EXISTS `ec_account`;
CREATE TABLE `ec_account` ( `id` BIGINT(20) NOT NULL , `name` VARCHAR(100) NOT NULL, INDEX `idx` (`id`)) ENGINE = MEMORY;
INSERT INTO ec_account (id, name) SELECT id,name FROM `account` WHERE latest = 1 AND name IS NOT NULL;
END$$
DELIMITER ;
DELIMITER $$
CREATE FUNCTION getTransactionType(type tinyint(4), subtype tinyint(4))
RETURNS char(100) DETERMINISTIC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment