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

refactor: merged supply charts into one endpoint #39

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

yevhen-burkovskyi
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Jun 19, 2024

Walkthrough

The modifications introduce a new feature that involves the addition of a CHARTS endpoint to retrieve specific chart data, which includes issuance, growth, and burnt values based on a specified range. The changes encompass the addition of a new enumeration, schema, and method in the service layer, along with corresponding updates in the controller to handle and validate the chart range inputs.

Changes

Files Change Summary
src/modules/supply/enums/supply-endpoints.enum.ts Added a new enum value CHARTS with the endpoint /charts in the SupplyEndpoints enum.
src/modules/supply/schemas/charts-range.schema.ts Introduced ChartsRangeSchema for Joi validation, restricting the range values to predefined options.
src/modules/supply/services/supply.service.ts Added an asynchronous method getCharts in SupplyService to retrieve issuance, growth, and burnt values based on a given range.
src/modules/supply/supply.controller.ts Renamed GrowthRangeSchema to ChartsRangeSchema and getSupplyGrowth to getCharts to align with new functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Service

    User->>+Controller: GET /charts?range={range}
    Controller->>+ChartsRangeSchema: Validate range
    alt valid range
        Controller->>+Service: getCharts(range)
        Service-->>-Controller: issuance, growth, burnt data
        Controller-->>-User: JSON response with data
    else invalid range
        Controller-->>-User: Error response (400 Bad Request)
    end
Loading

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 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 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 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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 656d0f0 and 63dd31b.

Files selected for processing (4)
  • src/modules/supply/enums/supply-endpoints.enum.ts (1 hunks)
  • src/modules/supply/schemas/charts-range.schema.ts (1 hunks)
  • src/modules/supply/services/supply.service.ts (1 hunks)
  • src/modules/supply/supply.controller.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/modules/supply/enums/supply-endpoints.enum.ts
Additional context used
Biome
src/modules/supply/supply.controller.ts

[error] 22-22: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 35-35: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 43-43: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

Additional comments not posted (3)
src/modules/supply/schemas/charts-range.schema.ts (1)

1-6: The ChartsRangeSchema is correctly defined using Joi validation to ensure that only specific predefined options are accepted. This is crucial for maintaining the integrity of the input data for the new charts endpoint.

src/modules/supply/supply.controller.ts (1)

41-46: The new getCharts method correctly utilizes the ChartsRangeSchema for validating the range parameter. This alignment ensures that the endpoint adheres to the expected schema constraints.

Tools
Biome

[error] 43-43: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

src/modules/supply/services/supply.service.ts (1)

188-198: The getCharts method is well-implemented, aggregating various metrics based on the provided range. However, the burnt value is statically set to 0. If this is a placeholder, consider adding a comment or creating a task to implement this metric fully in the future.

@@ -8,19 +8,19 @@ import { HistoricalRangeSchema } from "./schemas/historical-range.schema";
import { SupplyService } from "./services/supply.service";
import { ChangeRangeSchema } from "./schemas/change-range.schema";
import { Range } from "@core/enums/range.enum";
import { GrowthRangeSchema } from "./schemas/growth-range.schema";
import { ChartsRangeSchema } from "./schemas/charts-range.schema";
Copy link

Choose a reason for hiding this comment

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

The use of decorators on method parameters is flagged as invalid. You need to enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

+ // tsconfig.json
+ {
+   "compilerOptions": {
+     "unsafeParameterDecoratorsEnabled": true
+   }
+ }

Also applies to: 43-43

@yevhen-burkovskyi yevhen-burkovskyi self-assigned this Jun 19, 2024
@yevhen-burkovskyi yevhen-burkovskyi requested review from DraugS and removed request for DraugS June 19, 2024 18:41
@yevhen-burkovskyi yevhen-burkovskyi merged commit 98f3627 into main Jun 20, 2024
11 checks passed
@yevhen-burkovskyi yevhen-burkovskyi deleted the refactor/supply-charts branch June 20, 2024 16:43
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.

2 participants