|
|
|
@ -11,11 +11,14 @@ defmodule ExplorerWeb.PendingTransactionController do |
|
|
|
|
query = |
|
|
|
|
from( |
|
|
|
|
transaction in Transaction, |
|
|
|
|
left_join: receipt in assoc(transaction, :receipt), |
|
|
|
|
inner_join: to_address in assoc(transaction, :to_address), |
|
|
|
|
inner_join: from_address in assoc(transaction, :from_address), |
|
|
|
|
preload: [to_address: to_address, from_address: from_address], |
|
|
|
|
where: is_nil(receipt.transaction_id), |
|
|
|
|
where: |
|
|
|
|
fragment( |
|
|
|
|
"NOT EXISTS (SELECT true FROM receipts WHERE receipts.transaction_id = ?)", |
|
|
|
|
transaction.id |
|
|
|
|
), |
|
|
|
|
where: transaction.id < ^last_seen, |
|
|
|
|
order_by: [desc: transaction.id], |
|
|
|
|
limit: 10 |
|
|
|
@ -24,8 +27,11 @@ defmodule ExplorerWeb.PendingTransactionController do |
|
|
|
|
total_query = |
|
|
|
|
from( |
|
|
|
|
transaction in Transaction, |
|
|
|
|
left_join: receipt in assoc(transaction, :receipt), |
|
|
|
|
where: is_nil(receipt.transaction_id), |
|
|
|
|
where: |
|
|
|
|
fragment( |
|
|
|
|
"NOT EXISTS (SELECT true FROM receipts WHERE receipts.transaction_id = ?)", |
|
|
|
|
transaction.id |
|
|
|
|
), |
|
|
|
|
order_by: [desc: transaction.id], |
|
|
|
|
limit: 1 |
|
|
|
|
) |
|
|
|
@ -55,8 +61,11 @@ defmodule ExplorerWeb.PendingTransactionController do |
|
|
|
|
from( |
|
|
|
|
transaction in Transaction, |
|
|
|
|
select: transaction.id, |
|
|
|
|
left_join: receipt in assoc(transaction, :receipt), |
|
|
|
|
where: is_nil(receipt.transaction_id), |
|
|
|
|
where: |
|
|
|
|
fragment( |
|
|
|
|
"NOT EXISTS (SELECT true FROM receipts WHERE receipts.transaction_id = ?)", |
|
|
|
|
transaction.id |
|
|
|
|
), |
|
|
|
|
order_by: [desc: transaction.id], |
|
|
|
|
limit: 1 |
|
|
|
|
) |
|
|
|
|