Address PR feedback

Use view helper function for formatted_gas_used
Remove pipe for single call
Use pluralization for gettext with a count
pull/479/head
Tim Mecklem 6 years ago committed by katibest
parent ffbfe01871
commit cc5787137f
  1. 6
      apps/explorer_web/lib/explorer_web/templates/block/index.html.eex
  2. 4
      apps/explorer_web/lib/explorer_web/views/block_view.ex

@ -26,7 +26,7 @@
<div>
<!-- transactions -->
<span class="mr-2">
<%= gettext("%{count} transactions", count: block.transactions |> Enum.count) %>
<%= ngettext("%{count} transaction", "%{count} transactions", Enum.count(block.transactions)) %>
</span>
<!-- size -->
<span class="mr-2"> <%= Cldr.Unit.new(:byte, block.size) |> Cldr.Unit.to_string! %> </span>
@ -46,8 +46,8 @@
<div class="col-md-6 text-right d-flex flex-column align-items-end justify-content-end">
<!-- Gas Used -->
<div class="">
<%= block.gas_used |> Cldr.Number.to_string! %>
(<%= (block.gas_used / block.gas_limit) |> Cldr.Number.to_string!(format: "#.#%") %>)
<%= formatted_gas_used(block.gas_used) %>
(<%= formatted_gas_used(block.gas_used / block.gas_limit, format: "#.#%") %>)
<%= gettext "Gas Used" %>
</div>
<div class="progress w-25">

@ -20,6 +20,10 @@ defmodule ExplorerWeb.BlockView do
"#{average} #{unit_text}"
end
def formatted_gas_used(gas, format \\ []) do
Cldr.Number.to_string!(gas, format)
end
def formatted_timestamp(%Block{timestamp: timestamp}) do
Timex.format!(timestamp, "%b-%d-%Y %H:%M:%S %p %Z", :strftime)
end

Loading…
Cancel
Save