-
Notifications
You must be signed in to change notification settings - Fork 135
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
perf(db): Improve market-updater
task and getLatestPrice
query
#2730
Conversation
WalkthroughThe changes update the OraclePriceTable functionality. A method previously named Changes
Sequence Diagram(s)sequenceDiagram
participant MU as MarketUpdater
participant DB as Database
Note over MU: Start runTask
MU->>DB: Query liquidityTiers (parallel)
MU->>DB: Query perpetualMarkets (parallel)
MU->>DB: Query latestPricesBeforeOrAtHeight (parallel)
MU->>DB: Query prices24hAgo (parallel)
DB-->>MU: Return all results
Note over MU: Process and combine results
sequenceDiagram
participant PT as PnlTicksHelper
participant OP as OraclePriceTable
Note over PT: Requesting price data...
PT->>OP: findLatestPricesBeforeOrAtHeight(blockHeight)
OP-->>PT: Return price data
PT->>OP: findLatestPricesByDateTime(dateTime)
OP-->>PT: Return datetime-based prices
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
⏰ Context from checks skipped due to timeout of 90000ms (12)
🔇 Additional comments (7)
✨ Finishing Touches
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 (
|
24cf5d5
to
bbee832
Compare
@@ -219,7 +221,7 @@ export async function getLatestPrices(): Promise<PriceMap> { | |||
return findLatestPricesByDateTime(now); | |||
} | |||
|
|||
export async function findLatestPrices( | |||
export async function findLatestPricesBeforeOrAtHeight( |
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.
Update naming for disambiguation with findLatestPricesByDateTime
defaultOraclePrice.effectiveAtHeight, | ||
); | ||
|
||
expect(oraclePrices).toEqual(expect.objectContaining({ | ||
[defaultOraclePrice.marketId]: defaultOraclePrice.price, | ||
})); | ||
}); | ||
|
||
it('Successfully finds latest prices by dateTime using LEFT JOIN LATERAL', async () => { |
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.
Add missing unit test for findLatestPricesByDateTime
@@ -229,17 +231,19 @@ export async function findLatestPrices( | |||
WHERE ("marketId", "effectiveAtHeight") IN ( | |||
SELECT "marketId", MAX("effectiveAtHeight") | |||
FROM "oracle_prices" | |||
WHERE "effectiveAtHeight" <= '${effectiveBeforeOrAtHeight}' | |||
WHERE "effectiveAtHeight" <= ? |
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.
Prevent injection
market-updater
task and getLatestPrice
querymarket-updater
task and getLatestPrice
query
@Mergifyio backport release/indexer/v8.x |
✅ Backports have been created
|
Changelist
GetLatestBlockByDatetime
SQL query that makes use of index.GetLatestBlockByDatetime
market-updater
taskTest Plan
[Describe how this PR was tested (if applicable)]
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