|
|
|
@ -297,7 +297,7 @@ defmodule Explorer.Chain do |
|
|
|
|
query |
|
|
|
|
|> InternalTransaction.where_is_different_from_parent_transaction() |
|
|
|
|
|> InternalTransaction.where_block_number_is_not_null() |
|
|
|
|
|> page_internal_transaction(paging_options) |
|
|
|
|
|> page_internal_transaction(paging_options, %{index_int_tx_desc_order: true}) |
|
|
|
|
|> limit(^paging_options.page_size) |
|
|
|
|
|> order_by( |
|
|
|
|
[it], |
|
|
|
@ -4473,24 +4473,48 @@ defmodule Explorer.Chain do |
|
|
|
|
where(query, [coin_balance], coin_balance.block_number < ^block_number) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: nil}), do: query |
|
|
|
|
defp page_internal_transaction(_, _, _ \\ %{index_int_tx_desc_order: false}) |
|
|
|
|
|
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: {block_number, transaction_index, index}}) do |
|
|
|
|
where( |
|
|
|
|
query, |
|
|
|
|
[internal_transaction], |
|
|
|
|
internal_transaction.block_number < ^block_number or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index < ^transaction_index) or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index == ^transaction_index and internal_transaction.index < ^index) |
|
|
|
|
) |
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: nil}, _), do: query |
|
|
|
|
|
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: {block_number, transaction_index, index}}, %{ |
|
|
|
|
index_int_tx_desc_order: desc |
|
|
|
|
}) do |
|
|
|
|
hardcoded_where_for_page_int_tx(query, block_number, transaction_index, index, desc) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: {index}}) do |
|
|
|
|
where(query, [internal_transaction], internal_transaction.index > ^index) |
|
|
|
|
defp page_internal_transaction(query, %PagingOptions{key: {index}}, %{index_int_tx_desc_order: desc}) do |
|
|
|
|
if desc do |
|
|
|
|
where(query, [internal_transaction], internal_transaction.index < ^index) |
|
|
|
|
else |
|
|
|
|
where(query, [internal_transaction], internal_transaction.index > ^index) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp hardcoded_where_for_page_int_tx(query, block_number, transaction_index, index, false), |
|
|
|
|
do: |
|
|
|
|
where( |
|
|
|
|
query, |
|
|
|
|
[internal_transaction], |
|
|
|
|
internal_transaction.block_number < ^block_number or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index < ^transaction_index) or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index == ^transaction_index and internal_transaction.index > ^index) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
defp hardcoded_where_for_page_int_tx(query, block_number, transaction_index, index, true), |
|
|
|
|
do: |
|
|
|
|
where( |
|
|
|
|
query, |
|
|
|
|
[internal_transaction], |
|
|
|
|
internal_transaction.block_number < ^block_number or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index < ^transaction_index) or |
|
|
|
|
(internal_transaction.block_number == ^block_number and |
|
|
|
|
internal_transaction.transaction_index == ^transaction_index and internal_transaction.index < ^index) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
defp page_logs(query, %PagingOptions{key: nil}), do: query |
|
|
|
|
|
|
|
|
|
defp page_logs(query, %PagingOptions{key: {index}}) do |
|
|
|
|