-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat: optimize volumes endpoint when not using pit #608
Conversation
WalkthroughThe changes in this pull request primarily involve modifications to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
internal/storage/ledger/volumes.go (1)
105-143
: Consider refactoring to simplify complex conditional logicThe
selectVolumes
function contains multiple nested conditions that handle different scenarios. Refactoring the query construction into separate helper functions could improve readability and maintainability.For example, you could create helper functions like
buildVolumesQueryWithoutTimeFilters
andbuildVolumesQueryWithTimeFilters
to encapsulate the logic for each case.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
internal/storage/ledger/volumes.go
(2 hunks)
🔇 Additional comments (7)
internal/storage/ledger/volumes.go (7)
9-9
: Import usage of the features
package is appropriate
The features
package is correctly imported and utilized in the code, ensuring feature checks are performed where necessary.
105-105
: Declaration of selectVolumes
outside conditionals enhances clarity
Declaring selectVolumes
before the conditional blocks improves code readability and prevents scope-related issues.
107-116
: Efficient querying when time filters are not provided
When pit
and oot
are not provided, selecting volumes directly from the accounts_volumes
table optimizes performance by avoiding unnecessary computations.
117-119
: Proper feature check for FeatureMovesHistory
when time filters are used
Ensuring that the FeatureMovesHistory
feature is enabled when pit
or oot
are provided prevents unauthorized access to historical data and maintains system integrity.
121-125
: Dynamic selection of date filter column enhances flexibility
Assigning dateFilterColumn
based on useInsertionDate
allows the query to adapt to different filtering requirements, making the function more versatile.
126-136
: Comprehensive aggregation from the moves
table
Constructing the query to aggregate inputs, outputs, and balances from the moves
table accurately reflects account activities over time when time filters are applied.
137-143
: Correct application of time filters in the query
The conditions for pit
and oot
correctly modify the query to filter records based on the provided timestamps, ensuring accurate retrieval of data within the specified time range.
No description provided.