fix: logs list endpoint performance

pull/1868/head
zachdaniel 6 years ago
parent 584ad9952f
commit b15d645d57
  1. 1
      CHANGELOG.md
  2. 7
      apps/explorer/lib/explorer/etherscan/logs.ex

@ -13,6 +13,7 @@
- [#1840](https://github.com/poanetwork/blockscout/pull/1840) - Handle case when total supply is nil
- [#1838](https://github.com/poanetwork/blockscout/pull/1838) - Block counter calculates only consensus blocks
- [#1849](https://github.com/poanetwork/blockscout/pull/1849) - Improve chains menu
- [#1868](https://github.com/poanetwork/blockscout/pull/1868) - fix: logs list endpoint performance
### Chore

@ -5,7 +5,7 @@ defmodule Explorer.Etherscan.Logs do
"""
import Ecto.Query, only: [from: 2, where: 3]
import Ecto.Query, only: [from: 2, where: 3, subquery: 1, order_by: 3, limit: 2]
alias Explorer.Chain.Log
alias Explorer.Repo
@ -77,8 +77,6 @@ defmodule Explorer.Etherscan.Logs do
inner_join: b in assoc(t, :block),
where: b.number >= ^prepared_filter.from_block,
where: b.number <= ^prepared_filter.to_block,
order_by: b.number,
limit: 1_000,
select:
merge(map(l, ^@log_fields), %{
gas_price: t.gas_price,
@ -90,8 +88,11 @@ defmodule Explorer.Etherscan.Logs do
)
query
|> subquery()
|> where_address_match(prepared_filter)
|> where_topic_match(prepared_filter)
|> order_by([l], l.block_number)
|> limit(1_000)
|> Repo.all()
end

Loading…
Cancel
Save