-
Notifications
You must be signed in to change notification settings - Fork 115
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
Improve query to find candles map. #2650
Conversation
WalkthroughThe changes in this pull request primarily focus on refactoring the Changes
Possibly related PRs
Suggested labels
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: 1
🧹 Outside diff range and nitpick comments (3)
indexer/packages/postgres/src/stores/candle-table.ts (1)
199-199
: Consider making resolutions configurableHardcoding resolution values in the SQL queries reduces flexibility. Consider passing the desired resolutions as a parameter to the
findCandlesMap
function to make it adaptable to future changes or different use cases.Also applies to: 220-220
indexer/services/ender/src/caches/block-cache.ts (1)
110-110
: Use a more descriptive variable name for timestampConsider renaming
start
tostartTime
for better readability and to clearly indicate that it represents a timestamp.Apply this diff to rename the variable:
- const start: number = Date.now(); + const startTime: number = Date.now();Also, update the usage accordingly:
- Date.now() - start, + Date.now() - startTime,indexer/services/ender/__tests__/lib/candles-generator.test.ts (1)
311-312
: Ensure consistent use oftoUTC()
when convertingDateTime
to ISO stringsIn some places,
startedAt.toISO()
is used, and in others,startedAt.toUTC().toISO()
is used. For consistency and to ensure that all timestamps are in UTC, consider usingtoUTC().toISO()
throughout.Apply this diff to make the usage consistent:
- id: CandleTable.uuid(startedAt.toISO(), defaultCandle.ticker, CandleResolution.ONE_MINUTE), + id: CandleTable.uuid(startedAt.toUTC().toISO(), defaultCandle.ticker, CandleResolution.ONE_MINUTE),Repeat this change for other occurrences of
startedAt.toISO()
where UTC conversion is intended.Also applies to: 350-351, 363-363, 381-382, 403-403, 420-421, 470-470, 496-496
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
indexer/packages/postgres/src/stores/candle-table.ts
(2 hunks)indexer/services/ender/__tests__/lib/candles-generator.test.ts
(10 hunks)indexer/services/ender/src/caches/block-cache.ts
(2 hunks)indexer/services/ender/src/caches/candle-cache.ts
(0 hunks)
💤 Files with no reviewable changes (1)
- indexer/services/ender/src/caches/candle-cache.ts
🔇 Additional comments (2)
indexer/packages/postgres/src/stores/candle-table.ts (1)
178-180
:
Fix syntax error in the if
statement
A colon :
is used instead of an opening brace {
in the if
statement. In TypeScript, you should use {
to begin the code block after the condition.
Apply this diff to fix the syntax error:
- if (tickers.length === 0):
+ if (tickers.length === 0) {
Likely invalid or redundant comment.
indexer/services/ender/__tests__/lib/candles-generator.test.ts (1)
43-46
: Initialize startedAt
correctly using DateTime
The changes correctly initialize startedAt
as a DateTime
object using calculateNormalizedCandleStartTime
, ensuring accurate time calculations in the tests.
(cherry picked from commit 196dc84) # Conflicts: # indexer/services/ender/__tests__/lib/candles-generator.test.ts
@Mergifyio backport release/indexer/v8.x |
❌ Command disallowed due to command restrictions in the Mergify configuration.
|
@Mergifyio backport release/indexer/v8.x |
✅ Backports have been created
|
(cherry picked from commit 196dc84)
Changelist
Optimize queries to find initial map for candles by limiting the time period to search over for latest candles, and using a single query to get all the latest candles rather than repeated querying for a single ticker's candles.
Test Plan
Unit tests.
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
Bug Fixes
Tests
CandlesGenerator
to handle new date management withluxon
.Refactor