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

Add rebuildVolumeForAllMarkets() and migration to run it #808

Merged
merged 1 commit into from Feb 1, 2019

Conversation

ryanberckmans
Copy link
Contributor

rebuildVolumeForAllMarkets() was added to facilitate a recent volume fix which
required a full DB reset.

It can also be used in future unit testing to verify that incremental and
non-incremental methods of volume calculation produce the correct result.

Or as an ongoing sanity check: executing rebuildVolumeForAllMarkets() on a
production database should result in no changes.

Related to AugurProject/augur#289

rebuildVolumeForAllMarkets() was added to facilitate a recent volume fix which
required a full DB reset.

It can also be used in future unit testing to verify that incremental and
non-incremental methods of volume calculation produce the correct result.

Or as an ongoing sanity check: executing rebuildVolumeForAllMarkets() on a
production database should result in no changes.

Related to AugurProject/augur#289
@codeclimate
Copy link

codeclimate bot commented Feb 1, 2019

Code Climate has analyzed commit b3c621d and detected 4 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 2

View more on Code Climate.

return new Error(`marketId not found ${tradesRow.marketId}`);
}

const volumeFromThisTrade = volumeForTrade({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

// a client would just use rebuildVolumeForAllMarkets() which wraps this. But
// you may want to use this eg. for unit testing, to show that `incremental
// volume calculation for N trades` == `non-incremental volume calculation`.
function calculateVolumeForAllMarkets(allMarkets: Array<RebuildVolumeMarketsRow>, allTrades: Array<RebuildVolumeTradesRow>): RebuildVolumeResult | Error {
Copy link

Choose a reason for hiding this comment

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

Function calculateVolumeForAllMarkets has 39 lines of code (exceeds 25 allowed). Consider refactoring.

// a client would just use rebuildVolumeForAllMarkets() which wraps this. But
// you may want to use this eg. for unit testing, to show that `incremental
// volume calculation for N trades` == `non-incremental volume calculation`.
function calculateVolumeForAllMarkets(allMarkets: Array<RebuildVolumeMarketsRow>, allTrades: Array<RebuildVolumeTradesRow>): RebuildVolumeResult | Error {
Copy link

Choose a reason for hiding this comment

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

Function calculateVolumeForAllMarkets has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.

Copy link
Contributor

@nuevoalex nuevoalex left a comment

Choose a reason for hiding this comment

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

👍 Ran on prod and volume looks much better

@ryanberckmans ryanberckmans merged commit 3004fc4 into master Feb 1, 2019
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