Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix find block timestamp query #3374

Merged
merged 1 commit into from
Oct 20, 2020
Merged

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented Oct 20, 2020

Motivation

An error like this:

2020-10-20T12:47:04.925 [error] #PID<0.629.6> running BlockScoutWeb.Endpoint (connection #PID<0.628.6>, stream id 1) terminated
Request: GET /address/0x0B02534634092077Fbf73431867DB83A7B008084/coin-balances?type=JSON
** (exit) an exception was raised:
    ** (Ecto.MultipleResultsError) expected at most one result but got 2 in query:

from b0 in Explorer.Chain.Block,
  where: b0.number == ^12609315,
  select: b0.timestamp

        (ecto 3.3.4) lib/ecto/repo/queryable.ex:115: Ecto.Repo.Queryable.one/3
        (explorer 0.0.1) lib/explorer/chain.ex:4390: Explorer.Chain.address_to_coin_balances/2
        (block_scout_web 0.0.1) lib/block_scout_web/controllers/address_coin_balance_controller.ex:23: BlockScoutWeb.AddressCoinBalanceController.index/2
        (block_scout_web 0.0.1) lib/block_scout_web/controllers/address_coin_balance_controller.ex:1: BlockScoutWeb.AddressCoinBalanceController.action/2
        (block_scout_web 0.0.1) lib/block_scout_web/controllers/address_coin_balance_controller.ex:1: BlockScoutWeb.AddressCoinBalanceController.phoenix_controller_pipeline/2
        (phoenix 1.5.4) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
        (phoenix 1.5.4) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2
        (phoenix 1.5.4) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2

Changelog

Limit query results to one

Checklist for your Pull Request (PR)

@vbaranov vbaranov force-pushed the vb-fix-coin-balance-history-query branch from 5ab67e4 to 67b26f3 Compare October 20, 2020 16:11
@coveralls
Copy link

coveralls commented Oct 20, 2020

Pull Request Test Coverage Report for Build 67b26f376cf4a55a97319c5124fb4f8db34ec544-PR-3374

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-1.0%) to 67.591%

Files with Coverage Reduction New Missed Lines %
lib/block_scout_web/channels/address_channel.ex 2 36.96%
lib/block_scout_web/controllers/chain/market_history_chart_controller.ex 2 71.43%
Totals Coverage Status
Change from base Build 59085048dcb1851aa4c1b7394074cc2ce030e7ce: -1.0%
Covered Lines: 2048
Relevant Lines: 3030

💛 - Coveralls

@vbaranov vbaranov merged commit eb12407 into master Oct 20, 2020
@vbaranov vbaranov deleted the vb-fix-coin-balance-history-query branch May 9, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants