Sort pending transactions to the top of the transactions list

pull/2/head
Doc Ritezel 7 years ago
parent 3c9a9767c7
commit 19941e06dd
  1. 3
      lib/explorer_web/controllers/chain_controller.ex
  2. 2
      lib/explorer_web/controllers/transaction_controller.ex
  3. 4
      lib/explorer_web/templates/chain/show.html.eex
  4. 16
      lib/explorer_web/templates/transaction/index.html.eex
  5. 8
      priv/gettext/default.pot
  6. 8
      priv/gettext/en/LC_MESSAGES/default.po
  7. 4
      test/explorer_web/features/contributor_browsing_test.exs

@ -19,7 +19,8 @@ defmodule ExplorerWeb.ChainController do
left_join: block in assoc(block_transaction, :block),
preload: [block_transaction: block_transaction, block: block],
limit: 5,
order_by: [desc: block.number]
order_by: [desc: block.number],
where: not is_nil(block.id)
render(
conn,

@ -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: block.inserted_at]
order_by: [asc: fragment("? NULLS FIRST", block.inserted_at)]
transactions = Repo.paginate(query, params)

@ -48,8 +48,8 @@
<%= link(transaction.hash, to: transaction_path(@conn, :show, @conn.assigns.locale, transaction.hash), class: "blocks__link") %>
</div>
</td>
<td class="transactions__column transactions__column--block"><%= transaction.block && transaction.block.number || "" %></td>
<td class="transactions__column transactions__column--age"><%= transaction.block && transaction.block.timestamp |> Timex.from_now || "" %></td>
<td class="transactions__column transactions__column--block"><%= transaction.block.number %></td>
<td class="transactions__column transactions__column--age"><%= transaction.block.timestamp |> Timex.from_now %></td>
<td class="transactions__column transactions__column--value"><%= Decimal.div(Decimal.new(transaction.value), Decimal.new(1_000_000_000_000_000_000)) |> Decimal.to_string(:normal) %> <%= gettext "POA" %></td>
</tr>
<% end %>

@ -20,8 +20,20 @@
<td class="transactions__column transactions__column--hash">
<div class="transactions__hash"><%= link(transaction.hash, to: transaction_path(@conn, :show, @conn.assigns.locale, transaction.hash)) %></div>
</td>
<td class="transactions__column transactions__column--block"><%= link(transaction.block.number, to: block_path(@conn, :show, @conn.assigns.locale, transaction.block.number)) %></td>
<td class="transactions__column transactions__column--age"><%= transaction.block.timestamp |> Timex.from_now %></td>
<td class="transactions__column transactions__column--block">
<%= if is_nil(transaction.block_transaction) do %>
<%= gettext "Pending" %>
<% else %>
<%= link(transaction.block.number, to: block_path(@conn, :show, @conn.assigns.locale, transaction.block.number)) %>
<% end %>
</td>
<td class="transactions__column transactions__column--age">
<%= if is_nil(transaction.block_transaction) do %>
<%= gettext "Pending" %>
<% else %>
<%= transaction.block.timestamp |> Timex.from_now %>
<% end %>
</td>
<td class="transactions__column transactions__column--optional transactions__column--value"><%= Decimal.div(Decimal.new(transaction.value), Decimal.new(1_000_000_000_000_000_000)) |> Decimal.to_string(:normal) %> <%= gettext "POA" %></td>
</tr>
<% end %>

@ -146,7 +146,7 @@ msgstr ""
msgid "Overview"
msgstr ""
#: lib/explorer/forms/transaction_form.ex:75
#: lib/explorer/forms/transaction_form.ex:74
msgid "Success"
msgstr ""
@ -168,7 +168,7 @@ msgstr ""
#: lib/explorer_web/templates/address/show.html.eex:11
#: lib/explorer_web/templates/chain/show.html.eex:53
#: lib/explorer_web/templates/transaction/index.html.eex:25
#: lib/explorer_web/templates/transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/show.html.eex:38
msgid "POA"
msgstr ""
@ -185,6 +185,8 @@ msgstr ""
msgid "Showing %{count} Transactions"
msgstr ""
#: lib/explorer/forms/transaction_form.ex:77
#: lib/explorer/forms/transaction_form.ex:76
#: lib/explorer_web/templates/transaction/index.html.eex:27
#: lib/explorer_web/templates/transaction/index.html.eex:34
msgid "Pending"
msgstr ""

@ -158,7 +158,7 @@ msgstr "From"
msgid "Overview"
msgstr "Overview"
#: lib/explorer/forms/transaction_form.ex:75
#: lib/explorer/forms/transaction_form.ex:74
msgid "Success"
msgstr "Success"
@ -180,7 +180,7 @@ msgstr "Balance"
#: lib/explorer_web/templates/address/show.html.eex:11
#: lib/explorer_web/templates/chain/show.html.eex:53
#: lib/explorer_web/templates/transaction/index.html.eex:25
#: lib/explorer_web/templates/transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/show.html.eex:38
msgid "POA"
msgstr "POA"
@ -197,6 +197,8 @@ msgstr "Showing #%{start_block} to #%{end_block}"
msgid "Showing %{count} Transactions"
msgstr "Showing %{count} Transactions"
#: lib/explorer/forms/transaction_form.ex:77
#: lib/explorer/forms/transaction_form.ex:76
#: lib/explorer_web/templates/transaction/index.html.eex:27
#: lib/explorer_web/templates/transaction/index.html.eex:34
msgid "Pending"
msgstr "Pending"

@ -69,6 +69,8 @@ defmodule ExplorerWeb.UserListTest do
|> with_block(block)
|> with_addresses(%{to: "0xabelincoln", from: "0xhowardtaft"})
insert(:transaction)
session
|> visit("/en")
|> assert_has(css(".transactions__title", text: "Transactions"))
@ -77,6 +79,8 @@ defmodule ExplorerWeb.UserListTest do
|> assert_has(css(".transactions__column--age", count: 5))
|> click(link("Transactions"))
|> assert_has(css(".transactions__column--hash", text: "0xSk8"))
|> assert_has(css(".transactions__column--block", text: "Pending"))
|> assert_has(css(".transactions__column--age", text: "Pending"))
|> click(link("0xSk8"))
|> assert_has(css(".transaction__subheading", text: "0xSk8"))
|> assert_has(css(".transaction__item", text: "123,987"))

Loading…
Cancel
Save