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

New tables for staking pools and delegators #2036

Merged
merged 24 commits into from
May 30, 2019
Merged

New tables for staking pools and delegators #2036

merged 24 commits into from
May 30, 2019

Conversation

saneery
Copy link
Contributor

@saneery saneery commented May 27, 2019

#1709

Motivation

There is a need to store staking pools and delegators list in the separate tables.
In this PR I migrate staking pools from address_names table to the staking_pools table and add staking_pools_delegators table to store delegators.

Changelog

  • Add staking_pools table and schema
  • Add staking_pools_delegators table and schema
  • Migrate previous code from address_names table to the staking_pools table
  • Update PoolsReader to fetch delegators
  • Add import runner for delegators inserting

@coveralls
Copy link

coveralls commented May 27, 2019

Pull Request Test Coverage Report for Build bc053e24-e932-43e2-9ea9-ff51693d3a99

  • 47 of 53 (88.68%) changed or added relevant lines in 8 files are covered.
  • 8 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.1%) to 81.045%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/explorer/lib/explorer/chain/import/runner/staking_pools.ex 9 10 90.0%
apps/explorer/lib/explorer/chain/staking_pool.ex 5 6 83.33%
apps/indexer/lib/indexer/fetcher/staking_pools.ex 8 9 88.89%
apps/explorer/lib/explorer/chain/import/runner/staking_pools_delegators.ex 6 9 66.67%
Files with Coverage Reduction New Missed Lines %
apps/indexer/lib/indexer/fetcher/token.ex 1 78.57%
apps/explorer/lib/explorer/chain/hash.ex 2 84.62%
apps/indexer/lib/indexer/fetcher/token_balance.ex 2 87.1%
apps/indexer/lib/indexer/block/fetcher.ex 3 87.84%
Totals Coverage Status
Change from base Build 39afb760-d575-4350-be65-a1d921b93e71: -0.1%
Covered Lines: 4746
Relevant Lines: 5856

💛 - Coveralls

@saneery saneery marked this pull request as ready for review May 27, 2019 11:40
@saneery saneery self-assigned this May 27, 2019
@saneery saneery added the ready for review This PR is ready for reviews. label May 27, 2019
Copy link
Contributor

@pasqu4le pasqu4le left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only left a nitpick comment about names

@vbaranov vbaranov merged commit 191e3a6 into master May 30, 2019
@vbaranov vbaranov deleted the stakes-tables branch May 30, 2019 18:07
[pool],
pool.is_active == true and
pool.is_deleted == false and
pool.is_validator == true
Copy link
Contributor

@goodsoft goodsoft Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor comment, and the PR is merged anyway, but if you decide to change this code at some point, I would suggest using simplified where syntax here:

where(query, is_active: true, is_deleted: false, is_validator: true)

pool.delegators
|> Enum.map(&Map.get(&1, :changes))
|> Enum.concat(acc)
end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum.flat_map(pools, & &1.delegators.changes)?

@goodsoft goodsoft mentioned this pull request Jul 4, 2019
47 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants