Skip to content

chore: handle pricing when endtime is in future #112

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged

Conversation

thelostone-mc
Copy link
Contributor

@thelostone-mc thelostone-mc commented Apr 1, 2025

🤖 Linear

Closes PAR-XXX

Description

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced the token price retrieval process to automatically adjust timing parameters when a future end time is detected, ensuring more reliable and accurate pricing data.

Copy link

coderabbitai bot commented Apr 1, 2025

📝 Walkthrough

Walkthrough

The changes modify the getTokenPrice method in the CoingeckoProvider class. A new conditional block checks if the provided endTimestampMs is in the future compared to the current time. When it is, the method resets startTimestampMs to the current timestamp minus a predefined TIME_DELTA and updates endTimestampMs to the current timestamp. This ensures that the time range used for fetching token prices does not extend into the future. No modifications have been made to the declarations of exported or public entities.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🧹 Nitpick comments (1)
packages/pricing/src/providers/coingecko.provider.ts (1)

119-124: LGTM! Properly handles future timestamps.

The implementation correctly adjusts the time range when endTimestampMs is in the future, ensuring that Coingecko API calls only use past timestamps. This prevents potential errors or incomplete data from the API.

Consider extracting the buffer value (60 * 1000) to a named constant for better readability:

 // Handle when the endTimestampMs is in the future
-const currentTimestamp = Date.now() - 60 * 1000;
+const TIMESTAMP_BUFFER_MS = 60 * 1000; // One minute buffer
+const currentTimestamp = Date.now() - TIMESTAMP_BUFFER_MS;
 if (currentTimestamp < endTimestampMs) {
     startTimestampMs = (currentTimestamp - TIME_DELTA) as TimestampMs;
     endTimestampMs = currentTimestamp as TimestampMs;
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e50e1b1 and d64f4eb.

📒 Files selected for processing (1)
  • packages/pricing/src/providers/coingecko.provider.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.ts`:

**/*.ts:

  • packages/pricing/src/providers/coingecko.provider.ts
`**/providers/**/*.ts`: Review provider files for the following: - Providers should supply narrowly scoped data/resources. - Ensure classes interacting with metadata sources (e...

**/providers/**/*.ts: Review provider files for the following:

  • Providers should supply narrowly scoped data/resources.
  • Ensure classes interacting with metadata sources (e.g., GitHub, JSON
    files, IPFS) implement the IMetadataProvider interface and follow
    naming conventions (e.g., GithubProvider, JsonFileProvider).
  • Be concise and avoid overly nitpicky feedback outside of these best practices.
  • packages/pricing/src/providers/coingecko.provider.ts
🧬 Code Definitions (1)
packages/pricing/src/providers/coingecko.provider.ts (1)
packages/shared/src/types/common.ts (1)
  • TimestampMs (9-9)
⏰ Context from checks skipped due to timeout of 300000ms (1)
  • GitHub Check: e2e-tests / E2E Tests

@thelostone-mc thelostone-mc merged commit 98655ec into dev Apr 1, 2025
8 checks passed
@thelostone-mc thelostone-mc deleted the coingecko-fix branch April 1, 2025 10:15
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.

1 participant