Skip to content

Conversation

@chedieck
Copy link
Collaborator

@chedieck chedieck commented Nov 26, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced price synchronization workflow by adding an initial synchronization step to retrieve historical pricing data before processing missed transactions and data updates.
  • Chores

    • Updated database environment configuration variable mappings to align with current database service standards.
    • Enhanced logging for price synchronization operations to provide greater visibility into data synchronization processes.

✏️ Tip: You can customize this high-level summary in your review settings.

Greptile Overview

Greptile Summary

Fixed missing prices by ensuring syncPastDaysNewerPrices() runs before connecting transactions to prices in the blockchain sync worker. This prevents errors when connectAllTransactionsToPrices() attempts to link transactions to price data that doesn't exist yet.

  • Added syncPastDaysNewerPrices() call at the start of syncBlockchainAndPricesWorker job
  • Added logging to track price sync operations
  • Imported HUMAN_READABLE_DATE_FORMAT constant for improved log formatting

Issue found: Line 168 in priceService.ts logs the wrong variable - it outputs today's date instead of the actual last price date from the database.

Confidence Score: 3/5

  • Safe to merge after fixing the logging bug on line 168
  • The core fix correctly addresses missing prices by syncing them before connecting transactions. However, there's a logic error in the logging statement that outputs incorrect information (logs today's date instead of the last price date from DB), which could confuse debugging efforts.
  • services/priceService.ts needs the logging variable corrected on line 168

Important Files Changed

File Analysis

Filename Score Overview
jobs/workers.ts 5/5 Added syncPastDaysNewerPrices() call before syncing transactions to ensure required price data exists
services/priceService.ts 3/5 Added import for HUMAN_READABLE_DATE_FORMAT and logging statements. Critical bug: line 168 logs wrong variable

Sequence Diagram

sequenceDiagram
    participant Worker as syncBlockchainAndPricesWorker
    participant PriceService as priceService
    participant BlockchainClient as multiBlockchainClient
    participant TxService as transactionService
    participant DB as Database

    Worker->>PriceService: syncPastDaysNewerPrices()
    PriceService->>DB: Query last price timestamp
    DB-->>PriceService: lastPrice.timestamp
    PriceService->>PriceService: Calculate missing days
    PriceService->>PriceService: Log: Last price date (bug: logs today instead)
    PriceService->>PriceService: getAllPricesByNetworkTicker(XEC)
    PriceService->>PriceService: getAllPricesByNetworkTicker(BCH)
    PriceService->>DB: Upsert missing prices
    DB-->>PriceService: Success
    PriceService-->>Worker: Prices synced
    
    Worker->>BlockchainClient: syncMissedTransactions()
    BlockchainClient->>DB: Insert/update transactions
    DB-->>BlockchainClient: Success
    BlockchainClient-->>Worker: Transactions synced
    
    Worker->>TxService: connectAllTransactionsToPrices()
    TxService->>DB: Fetch transactions with no/irregular prices
    DB-->>TxService: Transaction list
    TxService->>DB: Bulk fetch prices for (networkId, timestamp) pairs
    DB-->>TxService: Price data
    alt Prices exist
        TxService->>DB: Create price-transaction links
        DB-->>TxService: Success
    else Prices missing
        TxService-->>Worker: Error thrown
    end
    TxService-->>Worker: Prices connected
Loading

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Warning

Rate limit exceeded

@chedieck has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1b7fea7 and 3fd6d6a.

📒 Files selected for processing (1)
  • jobs/workers.ts (1 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Added price sync call to the blockchain worker's initialization phase, enhanced logging in the price service with human-readable date formatting, and updated Docker Compose environment variables from MySQL to MariaDB naming conventions.

Changes

Cohort / File(s) Summary
Worker and pricing updates
jobs/workers.ts, services/priceService.ts
Added awaited call to priceService.syncPastDaysNewerPrices() at the start of syncBlockchainAndPricesWorker. Enhanced syncPastDaysNewerPrices() with two new log statements: last price date in human-readable format and count of prices to retrieve.
Docker configuration
docker-compose-from-dump.yml, docker-compose.yml
Renamed environment variables in db service from MySQL-style (MYSQL_ROOT_PASSWORD, MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD) to MariaDB-style (MARIADB_ROOT_PASSWORD, MARIADB_DATABASE, MARIADB_USER, MARIADB_PASSWORD) with all values preserved.

Sequence Diagram

sequenceDiagram
    participant Worker as syncBlockchainAndPricesWorker
    participant PriceService as priceService
    participant Logger as Logger

    Worker->>PriceService: syncPastDaysNewerPrices() [NEW]
    PriceService->>Logger: Log last price date (human-readable)
    PriceService->>Logger: Log count of prices to retrieve
    PriceService-->>Worker: Return
    Worker->>Worker: syncMissedTransactions()
    Worker->>Worker: connectPrices()
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Docker variable renaming is repetitive and straightforward across two files
  • Worker initialization change is a single awaited function call with minimal logic density
  • Enhanced logging statements are cosmetic with no behavioral impact

Possibly related PRs

Suggested reviewers

  • lissavxo

Poem

🐰 A worker hops to sync the chain,
With prices logged so bright and plain,
Date formats readable, clear and true,
MariaDB greeted, MySQL adieu!
The ledger bounces, all's well and well! 🌕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a Greptile analysis explaining the fix, identifies a logging bug, and documents changes made. However, it deviates from the repository's template structure (Missing "Related to #", "Depends on", and "Test plan" sections) and mixes Greptile's auto-generated content instead of the author's own narrative. Restructure the description to follow the template with clear sections for Related issue, Description, and Test plan. Remove or clearly separate auto-generated Greptile content from the author's own summary.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title "fix: missing prices" directly describes the main change in the changeset—adding a call to syncPastDaysNewerPrices() before connecting transactions to prices to prevent errors from missing price data.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

const date = moment().startOf('day')
const daysToRetrieve: string[] = []

console.log(`[PRICES] Last price found is for ${date.format(HUMAN_READABLE_DATE_FORMAT)}.`)
Copy link

Choose a reason for hiding this comment

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

logic: Logging wrong variable - should log lastDateInDB not date

Suggested change
console.log(`[PRICES] Last price found is for ${date.format(HUMAN_READABLE_DATE_FORMAT)}.`)
console.log(`[PRICES] Last price found is for ${lastDateInDB.format(HUMAN_READABLE_DATE_FORMAT)}.`)
Prompt To Fix With AI
This is a comment left during a code review.
Path: services/priceService.ts
Line: 168:168

Comment:
**logic:** Logging wrong variable - should log `lastDateInDB` not `date`

```suggestion
  console.log(`[PRICES] Last price found is for ${lastDateInDB.format(HUMAN_READABLE_DATE_FORMAT)}.`)
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
jobs/workers.ts (1)

38-41: Update the log message to reflect all operations.

The log message on line 38 says "syncing missed transactions and connecting prices..." but now the worker also syncs past prices at the start. Consider updating it to accurately describe all three operations.

Apply this diff to update the log message:

-      console.log(`job ${job.id as string}: syncing missed transactions and connecting prices...`)
+      console.log(`job ${job.id as string}: syncing past prices, missed transactions, and connecting prices...`)
       await priceService.syncPastDaysNewerPrices()

Additionally, the new execution order (sync prices → sync transactions → connect prices) makes sense because it ensures historical prices are up-to-date before processing transactions. However, note that if syncPastDaysNewerPrices() fails, the entire job will fail and subsequent operations won't execute. This appears to be the intended behavior given the existing error handling.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4ec079 and f11bc39.

📒 Files selected for processing (2)
  • jobs/workers.ts (1 hunks)
  • services/priceService.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
services/priceService.ts (1)
constants/index.ts (2)
  • HUMAN_READABLE_DATE_FORMAT (165-165)
  • PRICE_API_DATE_FORMAT (167-167)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests
🔇 Additional comments (2)
services/priceService.ts (2)

5-5: LGTM!

The import of HUMAN_READABLE_DATE_FORMAT is correctly added and used in the logging statement below.


173-173: LGTM!

The log correctly reports the number of prices that will be retrieved, improving observability of the sync operation.

@chedieck chedieck force-pushed the fix/missing-prices2 branch from f11bc39 to acb1744 Compare November 26, 2025 23:03
@chedieck chedieck merged commit 0b6bdfa into master Nov 26, 2025
3 checks passed
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.

3 participants