Browse Source

server: Simplify the light wallet transactions retrieval query

prometheus-integration
Alexis Hernandez 6 years ago
parent
commit
2db4f9f513
  1. 26
      server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala

26
server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala

@ -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
|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

Loading…
Cancel
Save