Change pending transaction conditions

pull/42/head
Doc Ritezel 7 years ago
parent 1751d1aed4
commit 549350fd6a
  1. 21
      lib/explorer_web/controllers/pending_transaction_controller.ex

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

Loading…
Cancel
Save