Sort transactions index by block.timestamp and transaction.inserted_at

pull/2/head
CJ Bryan and Matt Olenick 7 years ago committed by Doc Ritezel
parent 80e1f488a4
commit feef86e6b8
  1. 2
      lib/explorer_web/controllers/transaction_controller.ex
  2. 2
      test/explorer_web/controllers/transaction_controller_test.exs

@ -12,7 +12,7 @@ defmodule ExplorerWeb.TransactionController do
left_join: block_transaction in assoc(transaction, :block_transaction),
left_join: block in assoc(block_transaction, :block),
preload: [block_transaction: block_transaction, block: block],
order_by: [asc: fragment("? NULLS FIRST", block.inserted_at)]
order_by: [desc: block.timestamp, desc: transaction.inserted_at]
transactions = Repo.paginate(query, params)

@ -5,7 +5,7 @@ defmodule ExplorerWeb.TransactionControllerTest do
test "returns all transactions", %{conn: conn} do
transaction_ids = insert_list(4, :transaction) |> list_with_block |> Enum.map(fn (transaction) -> transaction.id end)
conn = get(conn, "/en/transactions")
assert conn.assigns.transactions |> Enum.map(fn (transaction) -> transaction.id end) == transaction_ids
assert conn.assigns.transactions |> Enum.map(fn (transaction) -> transaction.id end) |> Enum.reverse == transaction_ids
end
end

Loading…
Cancel
Save