|
|
@ -923,14 +923,15 @@ defmodule Explorer.Chain do |
|
|
|
@spec list_top_addresses :: [{Address.t(), non_neg_integer()}] |
|
|
|
@spec list_top_addresses :: [{Address.t(), non_neg_integer()}] |
|
|
|
def list_top_addresses do |
|
|
|
def list_top_addresses do |
|
|
|
query = |
|
|
|
query = |
|
|
|
from a in Address, |
|
|
|
from(a in Address, |
|
|
|
left_join: t in Transaction, |
|
|
|
left_join: t in Transaction, |
|
|
|
on: a.hash == t.from_address_hash, |
|
|
|
on: a.hash == t.from_address_hash, |
|
|
|
where: a.fetched_coin_balance > ^0, |
|
|
|
where: a.fetched_coin_balance > ^0, |
|
|
|
group_by: [a.hash, a.fetched_coin_balance], |
|
|
|
group_by: [a.hash, a.fetched_coin_balance], |
|
|
|
order_by: [desc: a.fetched_coin_balance, asc: a.hash], |
|
|
|
order_by: [desc: a.fetched_coin_balance, asc: a.hash], |
|
|
|
select: {a, fragment("coalesce(1 + max(?), 0)", t.nonce)}, |
|
|
|
select: {a, fragment("coalesce(1 + max(?), 0)", t.nonce)}, |
|
|
|
limit: 250 |
|
|
|
limit: 250 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
Repo.all(query) |
|
|
|
Repo.all(query) |
|
|
|
end |
|
|
|
end |
|
|
|