-
Notifications
You must be signed in to change notification settings - Fork 23
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
Feature hcmpre 1611 update target template #1289
base: console
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces significant enhancements to the campaign-related services in the project factory, focusing on target calculation, data processing, and validation logic. The changes span multiple files in the server-side implementation, introducing new utility functions for processing campaign data, refining target validation mechanisms, and improving the overall modularity of the code. The modifications aim to streamline how campaign targets are calculated, validated, and processed across different levels of granularity. Changes
Sequence DiagramsequenceDiagram
participant Client
participant GenericApis
participant CampaignUtils
participant Validators
Client->>GenericApis: Request target sheet data
GenericApis->>CampaignUtils: processDataForTargetCalculation
CampaignUtils-->>GenericApis: Processed data
GenericApis->>Validators: Validate targets
Validators-->>GenericApis: Validation result
GenericApis-->>Client: Return processed and validated data
Possibly Related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
health-services/project-factory/src/server/api/campaignApis.ts
(0 hunks)health-services/project-factory/src/server/api/genericApis.ts
(3 hunks)health-services/project-factory/src/server/utils/campaignUtils.ts
(9 hunks)health-services/project-factory/src/server/validators/campaignValidators.ts
(3 hunks)health-services/project-factory/src/server/validators/microplanValidators.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- health-services/project-factory/src/server/api/campaignApis.ts
🧰 Additional context used
🪛 Biome (1.9.4)
health-services/project-factory/src/server/utils/campaignUtils.ts
[error] 1716-1716: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
[error] 1708-1708: This let declares a variable that is only assigned once.
'totalTargetValue' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 2364-2364: This let declares a variable that is only assigned once.
'targets' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 2366-2366: This let declares a variable that is only assigned once.
'targetNo' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 2366-2366: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
[error] 2367-2367: This let declares a variable that is only assigned once.
'beneficiaryType' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 3035-3035: This let declares a variable that is only assigned once.
'rowData' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
🔇 Additional comments (8)
health-services/project-factory/src/server/utils/campaignUtils.ts (1)
28-28
: New import looks good.
This addition correctly imports the searchMDMS
function, improving modularity and reusability.
health-services/project-factory/src/server/api/genericApis.ts (3)
7-7
: Importing processDataForTargetCalculation
is well-structured.
This helps in keeping the processing logic decoupled and maintainable.
211-211
: Data fetching with row & sheet name metadata
This change, adding true,true
in getJsonData()
, ensures row numbers and sheet names are preserved. It can be helpful for debugging & error reporting.
227-227
: Delegating target calculation
Invoking processDataForTargetCalculation(...)
here centralizes the logic, improving readability and maintainability.
health-services/project-factory/src/server/validators/campaignValidators.ts (3)
25-25
: Renamed import for microplan validation
Replacing validateTargetsForMicroplanCampaigns
with validateRequiredTargetsForMicroplanCampaigns
clarifies intent, aligning with the usage in microplan scenarios.
91-133
: Refining target validation for normal campaigns
This block now checks for required columns, data ranges, and integer values. It enhances error details for better user feedback. Make sure to cover edge cases (e.g., extremely large inputs or negative numbers).
160-164
: Segregated flow for microplan vs. normal campaigns
Having a distinct path for microplan validations reduces confusion. Just ensure that shared logic doesn't diverge unnecessarily to avoid code duplication.
health-services/project-factory/src/server/validators/microplanValidators.ts (1)
131-131
: Renamed to validateRequiredTargetsForMicroplanCampaigns
This clearly indicates that the function enforces minimum required targets for each column, improving code readability. The numeric and integer checks are thorough.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation