ballerine
ballerine copied to clipboard
Bal 1644 - report in case management
User description
- Added Ongoing Monitoring alerts page
- Added Ongoing monitoring analysis sheet
Screenshots
Checklist
- [] I have read the contribution guidelines of this project
- [] I have read the style guidelines of this project
- [] I have performed a self-review of my own code
- [] I have commented my code, particularly in hard-to-understand areas
- [] I have made corresponding changes to the documentation
- [] My changes generate no new warnings and errors
- [] New and existing tests pass locally with my changes
PR Type
enhancement, tests
Changes walkthrough 📝
Relevant files | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Enhancement | 58 files
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tests | 1 files
|
💡 PR-Agent usage: Comment
/help
on the PR to get a list of all available PR-Agent tools and their descriptions
Summary by CodeRabbit
-
New Features
- Added new enum type
MonitoringType
for alerts and extendedAlertDefinition
to includemonitoringType
. - Introduced new alert definitions for merchant monitoring.
- Added
businessId
toAlert
for associating alerts with businesses. - New columns
reportId
andriskScore
added toBusinessReport
table.
- Added new enum type
-
Bug Fixes
- Adjusted alert generation functions to handle different alert types based on business or counterparty IDs.
-
Enhancements
- Updated Jest configuration and dependencies for improved testing.
- Enhanced
BusinessReportService
with new filtering and pagination capabilities. - Improved
TransactionService
error handling and logging.
-
Refactor
- Replaced
AlertService
withAlertDefinitionService
in controllers. - Renamed various DTOs and methods for better clarity.
- Replaced
-
Documentation
- Updated routing configuration and page components in the backoffice app for better navigation and new features.
-
Chores
- Added new data seeding scripts for business reports and alerts.
⚠️ No Changeset found
Latest commit: c6a0f236752011004e2d0ebebc05cc18e5480275
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
Walkthrough
The changes span configuration updates, schema migrations, and feature enhancements for the workflows service. Key updates include Jest configuration adjustments, database schema modifications to support new alert types and business reports, and enhancements to alert generation and business report seeding scripts. Additionally, the backoffice application routing has been restructured to include new pages and components.
Changes
File(s) | Change Summary |
---|---|
services/workflows-service/jest.config.ts |
Reorganized Jest settings, updated module paths, added TypeScript transform configuration, changed export |
services/workflows-service/package.json |
Added @jest/types v29.6.3, updated @types/jest to v26.0.24 |
services/workflows-service/prisma/migrations/.../migration.sql |
Added new enum MonitoringType , altered AlertDefinition and Alert tables, added businessId and reportId columns, added riskScore column, added additionalInfo JSONB column |
services/workflows-service/prisma/schema.prisma |
Added fields to Business , AlertDefinition , and Alert models, reorganized BusinessReport fields |
services/workflows-service/scripts/alerts/generate-alerts.ts , services/workflows-service/scripts/seed.ts |
Updated alert generation scripts, added merchant monitoring alert definitions, modified seeding process |
services/workflows-service/scripts/business-reports/seed-business-reports.ts |
Added functions to seed business reports and files using faker data and Prisma ORM |
services/workflows-service/src/alert/... |
Replaced AlertService with AlertDefinitionService , added MonitoringType , updated alert handling methods |
services/workflows-service/src/alert-definition/alert-definition.module.ts |
Included AlertDefinitionRepository in exports |
services/workflows-service/src/alert/types.ts |
Added types CheckRiskScoreOptions and CheckRiskScorePayload |
services/workflows-service/src/business-report/... |
Added methods for filtering and updating business reports, renamed some DTOs and methods |
services/workflows-service/src/collection-flow/collection-flow.module.ts , services/workflows-service/src/data-analytics/data-analytics.module.ts |
Added new module imports for alert and business report functionalities |
services/workflows-service/src/data-analytics/... |
Added risk score evaluation method, updated error message formatting |
services/workflows-service/src/transaction/transaction.service.ts |
Introduced correlationId , updated error handling, reordered dependencies |
apps/backoffice-v2/src/Router/Router.tsx |
Restructured routing configuration, added new page components |
services/workflows-service/prisma/data-migrations |
Updated subproject commit reference |
In code and schema, we weave our tale, With enums and alerts that now prevail. Business reports, they grow and seed, In Jest we trust, our tests proceed. Routing paths, a new array, For workflows bright as a spring day. 🌸
[!WARNING]
Review ran into problems
Problems (1)
- Git: Failed to clone repository. Please contact CodeRabbit support.
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?
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 full the 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.
PR Description updated to latest commit (https://github.com/ballerine-io/ballerine/commit/4828e8c54e545a1423003952140da115969b2bde)
PR Review 🔍
(Review updated until commit https://github.com/ballerine-io/ballerine/commit/9452a571364764ca6f09d226594576a9103af4d0)
⏱️ Estimated effort to review [1-5] |
5, because the PR introduces a significant amount of changes across multiple files and functionalities, including backend logic, database interactions, and scheduled tasks. The complexity and potential impact of these changes on the system's behavior require a thorough review to ensure correctness, performance, and maintainability. |
🧪 Relevant tests |
No |
⚡ Possible issues |
Possible Bug: The method |
Performance Concern: The | |
🔒 Security concerns |
No |
Code feedback:
relevant file | src/workflow/cron/ongoing-monitoring.cron.ts |
suggestion |
Consider implementing error handling for the lock release process in the |
relevant line | const lockReleased = await this.prisma.releaseLock(transaction, this.lockKey); |
relevant file | src/workflow/cron/ongoing-monitoring.cron.ts |
suggestion |
To improve performance and responsiveness of the |
relevant line | for (const business of businesses) { |
relevant file | src/common/app-logger/app-logger.service.ts |
suggestion |
Ensure that sensitive information is not logged by the |
relevant line | this.logger.error(`Failed to Invoke Ongoing Report for businessId: ${ |
relevant file | src/prisma/prisma.service.ts |
suggestion |
Optimize the database queries and indexes in the |
relevant line | const result = await transaction.$queryRaw |
PR Code Suggestions ✨
Category | Suggestions |
Maintainability |
Use a constant for repeated route path segments to improve maintainability.Consider using a constant for the repeated string '/:locale' in the route paths to ensure apps/backoffice-v2/src/Router/Router.tsx [115-139]
|
Refactor URL construction into a separate function for better code organization.Refactor the URL construction logic into a separate function to improve readability and apps/backoffice-v2/src/domains/alerts/fetchers.ts [113-116]
| |
Replace magic strings with constants or enums to improve code maintainability and prevent errors.Avoid using magic strings and instead use a constant or enum for the decision types.
| |
Extract complex configurations into separate functions or files to improve code maintainability.Extract the filter configuration into a separate function or file to improve readability apps/backoffice-v2/src/pages/BusinessesAlerts/components/AlertsFilters/AlertsFilters.tsx [38-66]
| |
Improve readability by renaming
| |
Reduce code duplication by creating a reusable function for null checks and fallback rendering.Refactor the repeated pattern of checking for null values and returning apps/backoffice-v2/src/pages/BusinessesAlerts/components/AlertsTable/columns.tsx [31-32]
| |
Use theme variables or CSS classes for colors to enhance maintainability and consistency.Replace the hardcoded color code with a theme variable or a CSS class to improve
| |
Extract inline styles to a CSS module for better readability and maintainability.Extract the inline styles into a separate CSS module to improve code readability and
| |
Best practice |
Remove debug logging from production code.Remove the console.log statement to avoid exposing potentially sensitive data and to apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx [49]
|
Use optional chaining to safely access properties of potentially undefined objects.Consider using optional chaining when accessing properties of potentially undefined apps/backoffice-v2/src/pages/BusinessesAlerts/BusinessesAlerts.page.tsx [30-32]
| |
Improve type safety by using more specific types.Use a more specific type for the
| |
Use CSS classes instead of inline styles to improve code readability and maintainability.Replace inline styles with class names defined in CSS files to separate concerns and apps/backoffice-v2/src/pages/BusinessesAlerts/components/AlertsHeader/AlertsHeader.tsx [86]
| |
Move inline styles to CSS for better maintainability.Avoid using inline styles for setting colors directly in the JSX. Instead, define these apps/backoffice-v2/src/pages/BusinessesAlerts/components/AlertsTable/columns.tsx [41]
| |
Use optional chaining to safely access properties on potentially null or undefined objects.Consider using optional chaining (
| |
Use descriptive prop names to improve code readability and maintainability.Use a more descriptive prop name than
| |
Use specific types for props to ensure type safety and clarity.Consider using a more specific type than
| |
Enhancement |
Improve error messages for better debugging and user experience.Add error handling for unsupported filter types to prevent runtime errors and improve user apps/backoffice-v2/src/common/components/organisms/Filters/Filters.Input.tsx [12]
|
Enhance conditional rendering to handle non-string and non-JSX elements gracefully.Use conditional rendering to handle different types of titles more explicitly, ensuring apps/backoffice-v2/src/common/components/organisms/Filters/Filters.Header.tsx [5-9]
| |
Improve type specificity for the
| |
Performance |
Optimize date formatting by reducing redundant calls to
|
PR Description updated to latest commit (https://github.com/ballerine-io/ballerine/commit/b1e439250065509f3b96362260417ece9ee16d29)
Persistent review updated to latest commit https://github.com/ballerine-io/ballerine/commit/b1e439250065509f3b96362260417ece9ee16d29
PR Code Suggestions ✨
Category | Suggestion | Score |
Best practice |
Replace
| 10 |
Replace console logging with proper error handling or loggingReplace the direct console logging with a more robust error handling or debugging
Suggestion importance[1-10]: 7Why: The suggestion is valid as replacing console.log with a more robust logging or error handling mechanism would improve the production quality of the code. | 7 | |
Enhancement |
Simplify the schema by using
| 8 |
Add a check for
| 7 | |
Error handling |
Improve error handling by throwing errors in the fetch functionIt is recommended to handle potential errors in the apps/backoffice-v2/src/domains/business-alerts/fetchers.ts [122]
Suggestion importance[1-10]: 8Why: This suggestion improves error handling by ensuring that errors are thrown and can be caught by error handling mechanisms upstream, rather than just returning the error. This is crucial for robust error management in asynchronous operations. | 8 |
Possible bug |
Add null checks before accessing object properties to prevent runtime errorsConsider adding a conditional rendering check for
Suggestion importance[1-10]: 8Why: This is a valuable suggestion as it addresses a potential runtime error by adding a conditional check before accessing properties of potentially null objects, which enhances the robustness of the code. | 8 |
Maintainability |
Define JSX components outside the router configuration to improve modularityAvoid using inline JSX in the router configuration as it can make the code harder to apps/backoffice-v2/src/Router/Router.tsx [119-138]
Suggestion importance[1-10]: 7Why: This suggestion correctly points out a best practice in React development to improve code modularity and maintainability by defining components outside of the router configuration. | 7 |
Ensure all optional fields are marked as optional for consistencyEnsure consistent handling of optional fields by applying apps/backoffice-v2/src/pages/BusinessesAlerts/get-alerts-search-schema.ts [27-30]
Suggestion importance[1-10]: 7Why: The suggestion promotes consistency and clarity by ensuring all optional fields are marked as such. However, the suggested code does not change from the existing code, making the suggestion somewhat redundant. | 7 | |
Group all imports from 'react' together at the top of the fileConsider using a consistent approach for importing React components and hooks. Currently, apps/backoffice-v2/src/Router/Router.tsx [26-18]
Suggestion importance[1-10]: 6Why: The suggestion correctly identifies an improvement in import organization for better readability and maintainability, though it's a relatively minor enhancement. | 6 | |
Refactor the toast action function into a separate utility file for better maintainabilityTo improve the readability and maintainability of the
Suggestion importance[1-10]: 6Why: The suggestion to refactor the | 6 | |
Consolidate multiple import statements from the same module into a single lineConsider using a single import statement for fetching functions from the same module to apps/backoffice-v2/src/domains/business-reports/query-keys.ts [3-5]
Suggestion importance[1-10]: 5Why: The suggestion correctly identifies an opportunity to consolidate import statements for better maintainability, but it's a minor improvement. | 5 | |
Validation |
Validate
| 7 |
User experience |
Replace throwing an error with a default component return for unsupported filter typesThe function apps/backoffice-v2/src/common/components/organisms/Filters/Filters.Input.tsx [12]
Suggestion importance[1-10]: 5Why: The suggestion to handle unsupported types more gracefully is valid and improves user experience, but it's not critical as it depends on the application's requirements for error handling. | 5 |
Performance |
Remove unnecessary use of
| 4 |
Persistent review updated to latest commit https://github.com/ballerine-io/ballerine/commit/9452a571364764ca6f09d226594576a9103af4d0
PR Code Suggestions ✨
Category | Suggestion | Score |
Security |
Enable parameter encoding in
| 10 |
Improve security by ensuring query parameters are properly encodedTo avoid potential security risks with query parameter injection, ensure that the apps/backoffice-v2/src/domains/alerts/fetchers.ts [113-114]
Suggestion importance[1-10]: 9Why: Properly encoding query parameters is crucial for preventing security risks such as query parameter injection. This suggestion significantly enhances the security of the code. | 9 | |
Performance |
Add dependencies to useCallback to prevent unnecessary re-computationsConsider adding a dependency array to the
Suggestion importance[1-10]: 10Why: Adding dependencies to the | 10 |
Possible issue |
Remove redundant code to improve clarity and efficiencyRemove the redundant call to
Suggestion importance[1-10]: 9Why: The suggestion correctly identifies and removes redundant code, improving both clarity and efficiency. This is a significant improvement to the code quality. | 9 |
Ensure navigation item keys are unique to avoid potential conflictsTo ensure that the 'nav-item-business-alerts' key is unique and does not cause conflicts
Suggestion importance[1-10]: 8Why: This suggestion addresses a potential issue with key conflicts in the navigation structure, which could cause bugs. Ensuring unique keys is important for the stability of the navigation component. | 8 | |
Replace
| 8 | |
Possible bug |
Add checks for
| 9 |
Handle potential null or undefined values before calling
| 9 | |
Define a specific schema for
| 7 | |
Best practice |
Prevent memory leaks by removing the link element after useTo prevent potential memory leaks and ensure that the created link element is properly apps/backoffice-v2/src/common/utils/save-base64-as-file/save-base64-as-file.ts [1-8]
Suggestion importance[1-10]: 8Why: This suggestion follows best practices by ensuring that the created link element is removed after use, preventing potential memory leaks. It is a good practice for resource management. | 8 |
Use a centralized utility function for consistent date and time formattingTo ensure the apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx [37-38]
Suggestion importance[1-10]: 8Why: This suggestion promotes best practices by advocating for the use of a centralized utility function for date formatting, ensuring consistency and reducing the likelihood of errors. It also simplifies future changes to date formats. | 8 | |
Enhancement |
Add error logging for better debugging and maintenanceAdd error logging within the catch block to help with debugging and maintaining the code.
Suggestion importance[1-10]: 8Why: Adding error logging is a good practice for debugging and maintenance. This suggestion enhances the code's maintainability and helps in diagnosing issues. | 8 |
Maintainability |
Refactor nested routes into a separate function to improve readability and maintainabilityTo improve the readability and maintainability of the routing configuration, consider apps/backoffice-v2/src/Router/Router.tsx [127-145]
Suggestion importance[1-10]: 7Why: This suggestion improves code readability and maintainability by refactoring nested routes into a separate function. However, it does not address any critical issues or bugs. | 7 |
Refactor complex inline expressions to improve code readabilityTo improve the readability and maintainability of the JSX code, consider breaking down apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx [72-79]
Suggestion importance[1-10]: 7Why: This suggestion enhances code readability and maintainability by refactoring complex inline expressions into well-named variables. It makes the code easier to understand and modify, which is beneficial for long-term maintenance. | 7 | |
Use descriptive or thematic class names for styling
| 6 | |
User experience |
Improve error messages for better user feedbackUse a more specific error message in the toast to provide better user feedback. For
Suggestion importance[1-10]: 7Why: While improving error messages can enhance user experience, the suggestion is relatively minor compared to others. It does provide better feedback but is not as critical as performance or debugging improvements. | 7 |