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
Conversation
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
Code Climate has analyzed commit b3c621d and detected 4 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
return new Error(`marketId not found ${tradesRow.marketId}`); | ||
} | ||
|
||
const volumeFromThisTrade = volumeForTrade({ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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