Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/lib/explorer/debit.ex

27 lines
687 B

defmodule Explorer.Debit do
@moduledoc """
A materialized view representing the debits from an address.
"""
use Ecto.Schema
alias Ecto.Adapters.SQL
alias Explorer.Address
alias Explorer.Repo
@timestamps_opts [type: Timex.Ecto.DateTime,
autogenerate: {Timex.Ecto.DateTime, :autogenerate, []}]
@primary_key false
schema "debits" do
belongs_to :address, Address, primary_key: true
field :value, :decimal
field :count, :integer
timestamps()
end
def refresh do
SQL.query!(Repo, "REFRESH MATERIALIZED VIEW CONCURRENTLY debits;", [], timeout: 120_000)
end
def null, do: %__MODULE__{value: Decimal.new(0), count: 0}
end