Skip to content
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/table asset main #716

Merged
merged 13 commits into from
Mar 25, 2024
Merged

Feat/table asset main #716

merged 13 commits into from
Mar 25, 2024

Conversation

phamphong9981
Copy link
Contributor

@phamphong9981 phamphong9981 commented Mar 21, 2024

Summary by CodeRabbit

  • New Features

    • Introduced automated asset information updates.
    • Added a new asset management functionality within the database.
  • Tests

    • Added unit tests for the new asset update functionality.
  • Chores

    • Configured job scheduling for asset updates.

Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

This update introduces a new feature for updating asset information in the system. It includes a configuration for a periodic job, a migration script for creating an asset database table, and the necessary model and service to handle asset updates. Additionally, constants are updated to support this new feature, and unit tests are added to ensure its correct functionality.

Changes

File Path Change Summary
ci/config.json.ci Added jobUpdateAssets configuration with job repetition and LCD record fetching parameters.
migrations/.../create_asset_model.ts Migration script for creating asset table with asset information columns.
src/common/constant.ts Added JOB_UPDATE_ASSETS constant and updated SERVICE object.
src/models/asset.ts Introduced Asset class with properties including ibc_channel.
src/services/.../update_assets.service.ts New service for updating asset information.
test/.../update_assets.spec.ts Tests for the UpdateAssetsJob service.

"In the code's vast meadow, under the silicon sky,
A rabbit hopped forth, with a gleeful cry.
🐇 'For assets anew, I've toiled through the night,
Through migrations and models, to make data just right.
With constants and services, all set in their place,
Let's update with joy, at a swift, steady pace.'"

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?

Share

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 868faad and 24d68e7.
Files ignored due to path filters (1)
  • config.json is excluded by: !**/*.json
Files selected for processing (6)
  • ci/config.json.ci (1 hunks)
  • migrations/20240110065150_create_asset_model.ts (1 hunks)
  • src/common/constant.ts (2 hunks)
  • src/models/asset.ts (1 hunks)
  • src/services/job/update_assets.service.ts (1 hunks)
  • test/unit/services/job/update_assets.spec.ts (1 hunks)
Additional comments: 12
migrations/20240110065150_create_asset_model.ts (3)
  • 10-10: Consider changing the price field type from float to decimal to avoid precision issues, especially since this field likely represents financial data. Using decimal provides exact precision, which is crucial for financial calculations.
  • 11-11: The total_supply field definition using decimal(80, 0) is appropriate for representing large numbers without fractional parts, suitable for asset supply quantities.
  • 13-13: The updated_at field is correctly defined with a timestamp type, set to not nullable, and defaults to the current timestamp. This ensures that every record will have an accurate timestamp upon creation.
src/models/asset.ts (2)
  • 5-24: The property definitions in the Asset class are well-defined and consistent with the database schema. The use of TypeScript's non-null assertion operator is appropriate, assuming these fields will always be populated. The inclusion of ibc_channel indicates a well-thought-out relational data model.
  • 30-40: The static properties TYPE and PREFIX in the Asset class are well-defined and promote consistency throughout the application by avoiding hard-coded strings. This is a good practice for maintainability and readability.
ci/config.json.ci (1)
  • 298-300: The addition of the jobUpdateAssets configuration with millisecondRepeatJob and lcdRecordGet parameters is well-defined. Ensure that the values for these parameters (10000 for millisecondRepeatJob and 5 for lcdRecordGet) are chosen based on the application's specific needs and performance considerations.
test/unit/services/job/update_assets.spec.ts (3)
  • 81-95: The setup and teardown methods using BeforeAll, AfterAll, and AfterEach decorators are correctly implemented to ensure a clean and isolated test environment. The use of TRUNCATE TABLE in the setup is particularly good practice for maintaining test isolation.
  • 103-103: The test case lacks a descriptive name. Consider adding a meaningful name that clearly describes what the test case is verifying. This improves readability and maintainability of the test suite.
  • 103-216: Consider enhancing the assertions in the test case to verify more properties of the assets, ensuring a thorough test coverage. This could include checking for specific values of properties like type, decimal, name, and others, to ensure the UpdateAssetsJob service is functioning as expected.
src/services/job/update_assets.service.ts (1)
  • 31-237: The implementation of the UpdateAssetsJob service, including querying assets from RPC, handling origin assets, and updating assets in the database, is well-structured and follows best practices. Ensure that floating-point numbers, such as total_supply, are handled carefully to avoid precision issues. The use of onConflict('denom').merge() for upserting assets is particularly noteworthy.
src/common/constant.ts (2)
  • 124-124: The addition of the JOB_UPDATE_ASSETS constant follows the established naming conventions and seems appropriate for the described functionality in the PR objectives.
  • 349-352: The addition of the UpdateAssets entry to the SERVICE object is consistent with the structure and conventions used throughout the file. It's clear and well-defined, facilitating easy identification and access to the service.

@peara peara merged commit 5989861 into main Mar 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants