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

fix: better violation names on statistics page (BAL-3294) #2932

Merged
merged 4 commits into from
Jan 5, 2025
Merged

Conversation

r4zendev
Copy link
Collaborator

@r4zendev r4zendev commented Jan 2, 2025

Changes

  • Changes expected shape of data that comes from the Unified API when calling for metrics
  • Adjusts front-end logic to work with new data shape

Note

This PR must be reviewed in conjunction with another PR opened against our private repository with Unified API.

Summary by CodeRabbit

  • New Features

    • Updated violation counts data structure to include more detailed information (name, id, count).
    • Improved routing for portfolio risk statistics using new identifier.
  • Bug Fixes

    • Adjusted data processing logic to work with new violation counts array format.
  • Refactor

    • Streamlined data handling in business report metrics and portfolio risk statistics components.

@r4zendev r4zendev self-assigned this Jan 2, 2025
Copy link

changeset-bot bot commented Jan 2, 2025

⚠️ No Changeset found

Latest commit: bf85463

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jan 2, 2025

Walkthrough

This pull request introduces a significant change to the structure of violationCounts across multiple services and components. The modification transforms violationCounts from a simple key-value record to an array of objects with name, id, and count properties. This change impacts the business reports metrics schema, affecting how violation data is represented and processed in the backoffice application and workflows service.

Changes

File Change Summary
apps/backoffice-v2/src/domains/business-reports/hooks/queries/useBusinessReportMetricsQuery/useBusinessReportMetricsQuery.ts Updated MetricsResponseSchema to use array of objects for violationCounts
apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/PortfolioRiskStatistics.tsx Added id property to filteredRiskIndicators mapping
apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/hooks/usePortfolioRiskStatisticsLogic/usePortfolioRiskStatisticsLogic.tsx Modified logic to process violationCounts as an array of objects
services/workflows-service/src/business-report/dtos/business-report-metrics-dto.ts Changed violationCounts type and description
services/workflows-service/src/business-report/merchant-monitoring-client.ts Updated MetricsResponseSchema to use array of objects for violationCounts

Possibly related PRs

  • blokh/feat/business report alerts #2311: The changes in the BusinessReportMetricsDto class regarding the violationCounts property are related to the modifications in the MetricsResponseSchema in the main PR, as both involve changing the structure of violationCounts from a record to an array of objects.
  • Fixed reports #2454: The BusinessReportSummary component's updates in this PR include changes to how data is processed, which may relate to the overall handling of business report metrics, particularly in how the violationCounts data might be displayed or summarized.
  • Additional swagger documentations #2767: The modifications to the OngoingMonitoringCron class and its logging enhancements may indirectly relate to the changes in how business report metrics are processed and reported, especially if they involve monitoring violations.
  • fix: browser back button functionality in merchant report page (BAL-3296) #2927: The enhancement of the browser back button functionality in the merchant report page could relate to the user experience when navigating reports that include the updated violationCounts structure, ensuring that users can easily return to previous states after viewing metrics.

Suggested labels

enhancement, Review effort [1-5]: 3

Suggested reviewers

  • Omri-Levy
  • MatanYadaev

Poem

🐰 Violation counts, once a simple map,
Now dance in arrays with newfound zap!
From records to objects, data takes flight,
Bringing structure that shines so bright.
A rabbit's code leap, precise and clean! 🚀


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>, 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

CodeRabbit Configuration 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
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: 2

🧹 Nitpick comments (2)
apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/hooks/usePortfolioRiskStatisticsLogic/usePortfolioRiskStatisticsLogic.tsx (1)

26-26: Consider avoiding in-place sorting to prevent mutating the array.

Using .sort() directly mutates violationCounts. For immutability (and fewer potential surprises in React), consider copying first:

- violationCounts
-   .sort((a, b) => ...)
+ [...violationCounts]
+   .sort((a, b) => ...)
apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/PortfolioRiskStatistics.tsx (1)

175-179: Use the unique ID as the component key.

While the new id parameter is used in the URL, the key is still tied to name. For better React rendering stability and uniqueness guarantees, consider switching to key={id}.

- <TableRow key={name} className={'border-b-0 hover:bg-[unset]'}>
+ <TableRow key={id} className={'border-b-0 hover:bg-[unset]'}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24dae62 and b9977f8.

📒 Files selected for processing (5)
  • apps/backoffice-v2/src/domains/business-reports/hooks/queries/useBusinessReportMetricsQuery/useBusinessReportMetricsQuery.ts (1 hunks)
  • apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/PortfolioRiskStatistics.tsx (1 hunks)
  • apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/hooks/usePortfolioRiskStatisticsLogic/usePortfolioRiskStatisticsLogic.tsx (1 hunks)
  • services/workflows-service/src/business-report/dtos/business-report-metrics-dto.ts (1 hunks)
  • services/workflows-service/src/business-report/merchant-monitoring-client.ts (1 hunks)
🔇 Additional comments (3)
apps/backoffice-v2/src/domains/business-reports/hooks/queries/useBusinessReportMetricsQuery/useBusinessReportMetricsQuery.ts (1)

15-21: Looks good and consistent with the new format.

Your Zod schema accurately reflects the array structure of violations.

apps/backoffice-v2/src/pages/Statistics/components/PortfolioRiskStatistics/hooks/usePortfolioRiskStatisticsLogic/usePortfolioRiskStatisticsLogic.tsx (1)

23-23: Accurate summation logic.

Summing all count properties correctly computes the total risk indicators.

services/workflows-service/src/business-report/merchant-monitoring-client.ts (1)

67-73: Schema alignment looks great.

Switching from a record to an array aligns well with the rest of the code changes and maintains consistency across the application.

@r4zendev r4zendev changed the title feat: better violation names on statistics page (BAL-3294) fix: better violation names on statistics page (BAL-3294) Jan 2, 2025
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: 0

🧹 Nitpick comments (1)
services/workflows-service/src/business-report/dtos/business-report-metrics-dto.ts (1)

60-71: Enhance API documentation for ViolationCountDto properties.

While the implementation is correct, consider adding more descriptive API documentation for better OpenAPI/Swagger documentation.

Apply this diff to improve the documentation:

 export class ViolationCountDto {
   @ApiProperty({
+    description: 'Unique identifier of the violation type',
+    example: 'PROHIBITED_CONTENT'
   })
   @IsString()
   id!: string;

   @ApiProperty({
+    description: 'Human-readable name of the violation',
+    example: 'Prohibited content'
   })
   @IsString()
   name!: string;

   @ApiProperty({
+    description: 'Number of occurrences of this violation',
+    example: 2
   })
   @IsNumber()
   count!: number;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9977f8 and 42cd2b0.

📒 Files selected for processing (1)
  • services/workflows-service/src/business-report/dtos/business-report-metrics-dto.ts (2 hunks)
🔇 Additional comments (2)
services/workflows-service/src/business-report/dtos/business-report-metrics-dto.ts (2)

2-2: LGTM! Appropriate validation decorators imported.

The added imports from class-validator are correctly chosen for validating the new array structure and its nested objects.


50-57: Well-structured implementation with proper validation!

The changes to violationCounts property are well-implemented:

  • Clear description and example
  • Proper validation using @IsArray() and @ValidateNested()
  • Type safety with @Type(() => ViolationCountDto)

@alonp99 alonp99 merged commit 6f0a6af into dev Jan 5, 2025
18 checks passed
@alonp99 alonp99 deleted the bal3294 branch January 5, 2025 20:52
chesterkmr pushed a commit that referenced this pull request Jan 6, 2025
* feat: better violation names on statistics page

* fix: CodeRabbit comments

---------

Co-authored-by: Alon Peretz <[email protected]>
chesterkmr added a commit that referenced this pull request Jan 28, 2025
* feat: added initial validator boilerplate & utilities & tests

* feat: implmeneted validate method & tests

* fix: test

* feat: implemented conditional validation rule apply & custom validators

* feat: implemented useValidate & tests

* feat: finalized validator component

* feat: added story for validator

* feat: added renderer & tests & dynamic form boilerplate

* feat: added rule engine

* feat: implemented dynamic form context logic & tests & types

* feat: finalized core form logic & finalized field list & tests

* fix: tests

* fix: build

* feat: added input boilerplates(unfinished) & field layout & tests

* feat: added fields (wip)

* fix: fixed build & tests

* feat: implemented events & fixed tests

* feat: implemented fields extend & removed elementsMap

* feat: added select field & fixed types & tests

* feat: added initial demo & bugfixes & updated tests

* feat: added phone field & tests & updated storybook

* feat: added file field & added tests & minor fixes

* feat: added clear value on input hide & updates tests

* feat: fixed onMount & onUnmount events & updated tests

* feat: added configurable file upload

* feat: added task runner & tests

* feat: implemented file upload on submit & tests

* feat: added more form stories & tests update

* feat: added custom validators & custom inputs examples

* feat: added radio field & tests

* feat: added tags input & tests & config fixes

* feat: added v2 adapters for custom fields & updated exports from ui & added tests (#2913)

* feat: added field descriptions & updated tests (#2914)

* feat: reworked ui elements for v2 & added tests (#2930)

* feat: reworked ui elements for v2 & added tests

* feat: added validate on blur

* feat: added initial rendering of UI V2

* feat: updated exports

* feat: implemented events provider

* feat: updated exports

* fix: listeners reinitialize

* feat: implemented document field

* feat: added document validator

* fix: fixed types

* fix: fixed tests & typo

* fix: fixed touched issue with non field definitions in form

* fix: updated validation params & cleanup

* fix: better violation names on statistics page (BAL-3294) (#2932)

* feat: better violation names on statistics page

* fix: CodeRabbit comments

---------

Co-authored-by: Alon Peretz <[email protected]>

* fix: renamed property in applyWhen rule

* feat: added url format & refactor

* Bal 3242 (#2939)

* feat: fixed types & exports & verbose logging & submit event

* feat: implemented plugins runner

* feat: updated types & minor adjustments to format string

* fix: document validator fixes & updated metadata

* feat: added submit button lock while tasks running

* feat: added metadata to useField & useElement & added missing format validator

* feat: added ref to form & fixed types & tests

* fix: fixed plugins context update & added plugin listeners

* feat: updated en translations

* fix: fixed kyb tests

* Bal 2977 (#2942)

* fix: css fixes & rule engine fixes

* feat: implemented sync

* feat: added classnames to row & column

* fix: submit button styles

* Bal 3330 (#2949)

* feat: added formatting for rules & updated tests

* feat: added transformer plugin

* fix: lock file

* feat: implemented priority fields & bug fixes & tests (#2950)

* fix: fixed build

* feat: implemented default data insertion on field list (#2951)

* feat: added support of html tags in descriptions

* feat: added useControl hook

* fix: reworked revision

* fix: fixed renderer stories

* Bal 3356 (WIP) (#2967)

* feat: implemented document field in ui package

* feat: finalized documentfield

* fix: fixed build

* fix: cleanup

* fix: fixed fieldlist

* feat: updated tests

* feat: added clear value for edge cases as documents

* fix: fixed tests & plugins

* fix: fixed fields extraction from definition

* fix: fixed infinite call of useRules due to default array value

* feat: enabled sync rules execution for controls disable and elements hiding

* feat: reworked cleanup

* feat: updated tests

* fix: added handling of dynamic indexes for useRquired & bugfixes

* fix: fixed types

* feat: added version to ui definition & added version resolving to kyb

* feat: reorganize

* feat: removed v1

* fix: post merge fixes & tests & reorganized folders

* fix: fixed state step tracking on submit

* fix: state sync fix

* fix: fixed tests

* feat: ui bump

* fix: fixed bug where dynamic indexes was not resolved in validation

* fix: bugfixes

* fix: cleanup

---------

Co-authored-by: Alon Peretz <[email protected]>
Co-authored-by: Sasha <[email protected]>
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