|
|
@ -115,30 +115,18 @@ class TransactionPostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderi |
|
|
|
limit: Limit)( |
|
|
|
implicit conn: Connection): List[Transaction] = { |
|
|
|
|
|
|
|
/** |
|
|
|
* TODO: Update query to: |
|
|
|
WITH CTE AS ( |
|
|
|
SELECT time AS lastSeenTime |
|
|
|
FROM transactions |
|
|
|
WHERE txid = {lastSeenTxid} |
|
|
|
) |
|
|
|
SELECT t.txid, t.blockhash, t.time, t.size |
|
|
|
FROM CTE CROSS JOIN transactions t |
|
|
|
JOIN address_transaction_details USING (txid) |
|
|
|
WHERE address = {address} AND |
|
|
|
(t.time < lastSeenTime OR (t.time = lastSeenTime AND t.txid > {lastSeenTxid})) |
|
|
|
ORDER BY time DESC |
|
|
|
LIMIT {limit} |
|
|
|
*/ |
|
|
|
SQL( |
|
|
|
""" |
|
|
|
|WITH CTE AS ( |
|
|
|
| SELECT time AS lastSeenTime |
|
|
|
| FROM transactions |
|
|
|
| WHERE txid = {lastSeenTxid} |
|
|
|
|) |
|
|
|
|SELECT t.txid, t.blockhash, t.time, t.size |
|
|
|
|FROM transactions t |
|
|
|
| JOIN address_transaction_details USING (txid) |
|
|
|
|FROM CTE CROSS JOIN transactions t |
|
|
|
| JOIN address_transaction_details USING (txid) |
|
|
|
|WHERE address = {address} AND |
|
|
|
| (t.time < (SELECT time AS lastSeenTime FROM transactions WHERE txid = {lastSeenTxid}) OR |
|
|
|
| (t.time = (SELECT time AS lastSeenTime FROM transactions WHERE txid = {lastSeenTxid}) AND |
|
|
|
| t.txid > {lastSeenTxid})) |
|
|
|
| (t.time < lastSeenTime OR (t.time = lastSeenTime AND t.txid > {lastSeenTxid})) |
|
|
|
|ORDER BY time DESC |
|
|
|
|LIMIT {limit} |
|
|
|
""".stripMargin |
|
|
|