Remove joins to address table

Co-authored-by: Stamates <stamates@hotmail.com>
pull/249/head
Tim Mecklem 7 years ago
parent 563273b2b1
commit a66e2b6e83
  1. 4
      apps/explorer_web/lib/explorer_web/controllers/transaction_controller.ex
  2. 10
      apps/explorer_web/lib/explorer_web/templates/address/_link.html.eex
  3. 4
      apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex
  4. 4
      apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex
  5. 4
      apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex
  6. 2
      apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex
  7. 4
      apps/explorer_web/lib/explorer_web/templates/chain/_transactions.html.eex
  8. 4
      apps/explorer_web/lib/explorer_web/templates/pending_transaction/index.html.eex
  9. 4
      apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex
  10. 4
      apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex
  11. 3
      apps/explorer_web/lib/explorer_web/views/address_view.ex

@ -22,9 +22,7 @@ defmodule ExplorerWeb.TransactionController do
Keyword.merge( Keyword.merge(
[ [
necessity_by_association: %{ necessity_by_association: %{
block: :required, block: :required
from_address: :optional,
to_address: :optional
} }
], ],
options options

@ -1,14 +1,14 @@
<div class="address-link"> <div class="address-link">
<%= if @address do %> <%= if @address_hash do %>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, @address), <%= link to: address_path(@conn, :show, @conn.assigns.locale, @address_hash),
"data-toggle": "tooltip", "data-toggle": "tooltip",
"data-placement": "top", "data-placement": "top",
class: "address-link__font", class: "address-link__font",
title: @address do %> title: @address_hash do %>
<i class="address-link__type fas fa-address-card"></i> <i class="address-link__type fas fa-address-card"></i>
<%= @address |> hash |> String.slice(0..3) %><i class="fas fa-ellipsis-v address-link__seperator"></i><%= @address |> hash |> String.slice(-4..-1) %> <%= @address_hash |> hash() |> String.slice(0..3) %><i class="fas fa-ellipsis-v address-link__seperator"></i><%= @address_hash |> hash() |> String.slice(-4..-1) %>
<% end %> <% end %>
<button class="address-link__copy-button" data-clipboard-text="<%= @address %>" aria-label="copy address"> <button class="address-link__copy-button" data-clipboard-text="<%= @address_hash %>" aria-label="copy address">
<i class="fa fa-copy"></i> <i class="fa fa-copy"></i>
</button> </button>
<% end %> <% end %>

@ -96,10 +96,10 @@
</td> </td>
<td><%= ExplorerWeb.BlockView.age(internal_transaction.transaction.block) %></td> <td><%= ExplorerWeb.BlockView.age(internal_transaction.transaction.block) %></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: internal_transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: internal_transaction.to_address_hash %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>
</tr> </tr>

@ -103,11 +103,11 @@
</td> </td>
<td><%= transaction.block.timestamp |> Timex.from_now %></td> <td><%= transaction.block.timestamp |> Timex.from_now %></td>
<td class="address-cell"> <td class="address-cell">
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.from_address_hash %>
</td> </td>
<td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td> <td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.to_address_hash %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %></td>
<td><%= ExplorerWeb.TransactionView.formatted_fee(transaction, denomination: :ether) %></td> <td><%= ExplorerWeb.TransactionView.formatted_fee(transaction, denomination: :ether) %></td>

@ -164,11 +164,11 @@
<%= transaction.block.timestamp |> Timex.from_now %> <%= transaction.block.timestamp |> Timex.from_now %>
</td> </td>
<td class="address-cell"> <td class="address-cell">
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.from_address_hash %>
</td> </td>
<td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td> <td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.to_address_hash %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction) %> <%= ExplorerWeb.TransactionView.value(transaction) %>

@ -21,7 +21,7 @@
<td><%= block.transactions |> Enum.count %></td> <td><%= block.transactions |> Enum.count %></td>
<td><%= block.gas_used |> Cldr.Number.to_string! %></td> <td><%= block.gas_used |> Cldr.Number.to_string! %></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: block.miner %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: block.miner_hash %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

@ -17,10 +17,10 @@
<%= render ExplorerWeb.TransactionView, "_link.html", conn: @conn, transaction: transaction %> <%= render ExplorerWeb.TransactionView, "_link.html", conn: @conn, transaction: transaction %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.to_address_hash %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> </td> <td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> </td>
<td><%= transaction.block.timestamp |> Timex.from_now() %></td> <td><%= transaction.block.timestamp |> Timex.from_now() %></td>

@ -50,10 +50,10 @@
</td> </td>
<td><%= last_seen(transaction) %></td> <td><%= last_seen(transaction) %></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.to_address_hash %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -59,10 +59,10 @@
<%= transaction.block.timestamp %> <%= transaction.block.timestamp %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: transaction.to_address_hash %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -38,10 +38,10 @@
<tr> <tr>
<td><%= internal_transaction.call_type %></td> <td><%= internal_transaction.call_type %></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: internal_transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address_hash: internal_transaction.to_address_hash %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>
<td><%= ExplorerWeb.TransactionView.gas(internal_transaction) %></td> <td><%= ExplorerWeb.TransactionView.gas(internal_transaction) %></td>

@ -2,6 +2,7 @@ defmodule ExplorerWeb.AddressView do
use ExplorerWeb, :view use ExplorerWeb, :view
alias Explorer.Chain.{Address, Wei} alias Explorer.Chain.{Address, Wei}
alias Explorer.Chain.Hash
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
alias ExplorerWeb.ExchangeRates.USD alias ExplorerWeb.ExchangeRates.USD
@ -41,7 +42,7 @@ defmodule ExplorerWeb.AddressView do
end end
end end
def hash(%Address{hash: hash}) do def hash(%Hash{} = hash) do
to_string(hash) to_string(hash)
end end

Loading…
Cancel
Save