-
Notifications
You must be signed in to change notification settings - Fork 19
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
User usage column changes #1293
Conversation
* Update campaignApis.ts * Update campaignUtils.ts (#1279)
#1285) feat: Add parentId and isActive columns to eg_cm_campaign_details, remove unique constraint on campaignName
* feat: Add parentId and isActive columns to eg_cm_campaign_details, remove unique constraint on campaignName * Fix : user mapping
Warning Rate limit exceeded@ashish-egov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 2 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughWalkthroughThe recent changes enhance the project factory service's functionality, focusing on campaign management and validation. Key updates include new columns in the database for hierarchical relationships, refined validation logic for campaigns, and improved error handling. Adjustments to the logging and data structure streamline operations, while the introduction of new constants and functions aids in better campaign tracking and management. These modifications collectively aim to improve clarity, data integrity, and user experience. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Validator
participant Database
User->>API: Create Campaign Request
API->>Validator: Validate Campaign Data
Validator-->>API: Validation Result
API->>Database: Save Campaign Details
Database-->>API: Confirmation
API-->>User: Campaign Created
Poem
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 1
Outside diff range, codebase verification and nitpick comments (5)
utilities/project-factory/migration/main/V20240814121200__campaign_details_add_column.sql (2)
1-2
: Ensure the new columnparentId
is indexed if necessary.Adding the
parentId
column as acharacter varying(128)
is fine, but consider indexing it if it will be used in queries to improve performance.
4-5
: Consider default values for theisActive
column.Adding the
isActive
column as a boolean without a default value may lead toNULL
values. Consider setting a default value to ensure data consistency.ALTER TABLE eg_cm_campaign_details ADD COLUMN "isActive" boolean DEFAULT false;utilities/project-factory/migration/main/V20240814180000__campaign_details_add_column.sql (2)
10-11
: Consider indexing theparentid
column if necessary.Adding the
parentid
column as acharacter varying(128)
is fine, but consider indexing it if it will be used in queries to improve performance.
13-13
: Consider default values for theisactive
column.Adding the
isactive
column as a boolean without a default value may lead toNULL
values. Consider setting a default value to ensure data consistency.ALTER TABLE eg_cm_campaign_details ADD COLUMN isactive boolean DEFAULT false;utilities/project-factory/src/server/config/models/campaignDetails.ts (1)
22-22
: Update references tochangeDates
in the codebase.The removal of
changeDates
from theaction
enum requires updating the following parts of the codebase wherechangeDates
is still referenced:
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js
:changeDatesEnabled
is set totrue
.micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
:isChangeDates
is used, andpayloadData.action
is assigned"changeDates"
.These references need to be revised to ensure consistency with the updated enum values.
Analysis chain
Removal of
changeDates
from theaction
enum.The removal of
changeDates
limits valid actions tocreate
anddraft
.Ensure that any application logic relying on
changeDates
is updated to reflect this change.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify impact of removing `changeDates` from the `action` enum. # Test: Search for usage of `changeDates`. Expect: No dependencies on this removed option. rg --type js 'changeDates'Length of output: 467
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (14)
- .github/workflows/publishProjectFactory.yml (1 hunks)
- utilities/project-factory/migration/main/V20240814121200__campaign_details_add_column.sql (1 hunks)
- utilities/project-factory/migration/main/V20240814180000__campaign_details_add_column.sql (1 hunks)
- utilities/project-factory/src/server/api/campaignApis.ts (1 hunks)
- utilities/project-factory/src/server/config/constants.ts (1 hunks)
- utilities/project-factory/src/server/config/createAndSearch.ts (1 hunks)
- utilities/project-factory/src/server/config/index.ts (1 hunks)
- utilities/project-factory/src/server/config/models/campaignDetails.ts (1 hunks)
- utilities/project-factory/src/server/config/models/searchCampaignDetails.ts (1 hunks)
- utilities/project-factory/src/server/kafka/Listener.ts (1 hunks)
- utilities/project-factory/src/server/utils/campaignUtils.ts (8 hunks)
- utilities/project-factory/src/server/utils/transforms/searchResponseConstructor.ts (1 hunks)
- utilities/project-factory/src/server/validators/campaignValidators.ts (10 hunks)
- utilities/project-factory/src/server/validators/genericValidator.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- .github/workflows/publishProjectFactory.yml
- utilities/project-factory/src/server/config/index.ts
Additional context used
Biome
utilities/project-factory/src/server/validators/campaignValidators.ts
[error] 948-948: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
Additional comments not posted (20)
utilities/project-factory/migration/main/V20240814121200__campaign_details_add_column.sql (1)
7-8
: Verify the impact of dropping the unique constraint.Dropping the
eg_cm_campaign_details_campaignName_key
constraint may affect data integrity if thecampaignName
was intended to be unique. Ensure that this change aligns with the overall data model requirements.utilities/project-factory/migration/main/V20240814180000__campaign_details_add_column.sql (2)
3-3
: Ensure data migration forparentId
.Dropping the
parentId
column and re-adding it with a lowercase name may lead to data loss. Ensure that data migration steps are in place to preserve existing data.
6-6
: Ensure data migration forisActive
.Dropping the
isActive
column and re-adding it with a lowercase name may lead to data loss. Ensure that data migration steps are in place to preserve existing data.utilities/project-factory/src/server/kafka/Listener.ts (1)
31-32
: Logging improvements look good.The changes to log the received message immediately after parsing enhance the clarity of the logs and help in debugging. This is a good practice.
utilities/project-factory/src/server/config/models/searchCampaignDetails.ts (1)
50-52
: Addition ofisActive
property looks good.The
isActive
property enhances the schema by allowing campaigns to be tracked based on their active status.Ensure that the application logic correctly handles this new property where necessary.
Verification successful
Usage of
isActive
Property VerifiedThe
isActive
property is actively used in the application logic across several components and modules, indicating that it is integrated into the codebase as expected. The usages involve condition checks and default value settings, which align with the intended purpose of tracking active status.
- Files with
isActive
usage:
SelectingBoundaries.js
SetupCampaign.js
DateWithBoundary.js
Module.js
- Various modal components in
ApplicationDetails
These usages suggest that the application logic appropriately handles the
isActive
property.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of the `isActive` property in the codebase. # Test: Search for the usage of `isActive`. Expect: Appropriate handling in application logic. rg --type js 'isActive'Length of output: 3038
utilities/project-factory/src/server/utils/transforms/searchResponseConstructor.ts (1)
42-43
: Addition ofisActive
andparentId
properties in the transformer.These properties enhance the campaign details by supporting active status tracking and hierarchical relationships.
Ensure that these new properties are correctly integrated into the application logic.
Verification successful
parentId
is correctly integrated into the application logic.The
parentId
property is utilized in various parts of the codebase, including validation functions and utility scripts, indicating its integration into the application logic.
- Files and Usage:
utilities/project-factory/src/server/validators/campaignValidators.ts
: Used in processing boundaries and campaign details.utilities/project-factory/src/server/utils/campaignUtils.ts
: Manipulated within campaign utility functions.utilities/project-factory/src/server/utils/transforms/searchResponseConstructor.ts
: Added as a property in the transformer.These findings confirm the integration of
parentId
into the application logic.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of the `isActive` and `parentId` properties in the codebase. # Test: Search for the usage of `isActive` and `parentId`. Expect: Appropriate handling in application logic. rg --type js 'isActive|parentId'Length of output: 3049
Script:
#!/bin/bash # Description: Verify usage of the `parentId` property specifically in the codebase. # Test: Search for the usage of `parentId`. Expect: Appropriate handling in application logic. rg --type js 'parentId'Length of output: 23
Script:
#!/bin/bash # Description: Verify usage of the `parentId` property in the codebase, including other file types. # Test: Search for the usage of `parentId` in various file types. rg 'parentId'Length of output: 2085
utilities/project-factory/src/server/config/constants.ts (1)
38-38
: Addition ofPARENT_CAMPAIGN_ERROR
is appropriate.The new constant
PARENT_CAMPAIGN_ERROR
enhances error specificity for missing parent campaigns, aligning well with existing error messages.utilities/project-factory/src/server/validators/genericValidator.ts (1)
Line range hint
104-109
: Verify date handling invalidateCampaign
.The removal of date conversion logic in
validateCampaign
could affect how campaign dates are validated. Ensure that date handling is addressed elsewhere if needed.utilities/project-factory/src/server/config/createAndSearch.ts (1)
352-355
: Column identifier updates are appropriate.The changes to
uniqueIdentifierColumn
,activeColumn
, andactiveColumnName
enhance data management capabilities. Ensure consistency with other system components that use these identifiers.utilities/project-factory/src/server/api/campaignApis.ts (1)
796-798
: Ensure Consistency inactivityObject
Construction.The change encapsulates
request.body.Activities
in an object with theActivities
key. This improves data structure consistency. Verify that all downstream functions handle this new structure correctly.Verification successful
Verification Complete:
activityObject
Structure is ConsistentThe
activityObject
is correctly structured and passed toproduceModifiedMessages
, which handles it as expected. No issues found with the downstream handling of this change.
- The
produceModifiedMessages
function is used appropriately with the new structure ofactivityObject
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all downstream functions handle the new structure of `activityObject`. # Test: Search for all usages of `produceModifiedMessages` to ensure they handle the new structure. rg --type typescript -A 5 $'produceModifiedMessages'Length of output: 86
Script:
#!/bin/bash # Description: Verify that all downstream functions handle the new structure of `activityObject`. # Test: Search for all usages of `produceModifiedMessages` to ensure they handle the new structure. rg --type ts -A 5 $'produceModifiedMessages'Length of output: 18387
utilities/project-factory/src/server/validators/campaignValidators.ts (4)
678-688
: Review thevalidateRootBoundaryWithParent
Function Logic.This function ensures that the root boundary code of a campaign matches its parent campaign. This is a critical validation to maintain hierarchical consistency. Verify that the
getRootBoundaryCode
function is correctly implemented and used.
861-869
: Enhance Date Validation Logic invalidateDraftProjectCampaignMissingFields
.The function now checks that
startDate
cannot be today or a past date, which strengthens the validation rules. Ensure that this logic aligns with the overall business rules and scenarios.
871-896
: Review thevalidateParent
Function for Parent Campaign Validation.This function constructs a search request to verify the existence and status of the parent campaign. Ensure that the search logic correctly handles various scenarios, such as missing or inactive parent campaigns.
Line range hint
915-937
:
Refine Campaign Name Validation Logic.The logic now uses a filter and loop to handle campaign name conflicts, improving error handling. Ensure that the conditions for throwing errors are comprehensive and cover all edge cases.
utilities/project-factory/src/server/utils/campaignUtils.ts (6)
567-568
: LGTM!The addition of
isActive
and handling ofparentId
are correctly implemented.
611-611
: LGTM!The streamlined status assignment logic is correctly implemented.
640-650
: LGTM!The
makeParentInactive
function is correctly implemented to manage theisActive
status of a parent campaign.
493-493
: LGTM!The
getRootBoundaryCode
function is correctly exported for use in other modules.
193-218
: LGTM! But verify the function usage in the codebase.The changes to the column references for "UserName" and "Password" are correctly implemented.
Ensure that all function calls to
deterMineLastColumnAndEnrichUserDetails
accommodate these changes.Verification successful
Function Usage Verified
The function
deterMineLastColumnAndEnrichUserDetails
is called within the same file where it is defined. The usage appears to be consistent with the changes made to the column references for "UserName" and "Password". No additional occurrences were found in other files, indicating that the function's usage is localized and likely does not impact other parts of the codebase.
- File:
utilities/project-factory/src/server/utils/campaignUtils.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `deterMineLastColumnAndEnrichUserDetails` match the updated column references. # Test: Search for the function usage. Expect: Occurrences of the function with updated references. rg --type typescript -A 5 $'deterMineLastColumnAndEnrichUserDetails'Length of output: 102
Script:
#!/bin/bash # Description: Verify all function calls to `deterMineLastColumnAndEnrichUserDetails` match the updated column references. # Test: Search for the function usage in .ts files. Expect: Occurrences of the function with updated references. rg --glob '*.ts' -A 5 'deterMineLastColumnAndEnrichUserDetails'Length of output: 1525
1385-1385
: Verify the impact of commenting outupdateProjectDates
.The function no longer updates project dates after persistence. Ensure this change aligns with the overall system requirements.
Verification successful
No external dependencies found for
updateProjectDates
.The
updateProjectDates
function is not referenced elsewhere in the codebase, indicating that commenting it out does not break any dependencies. However, ensure that the logic it provided is not needed elsewhere or has been replaced by other logic.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of commenting out `updateProjectDates`. # Test: Search for the function usage to ensure no dependencies are broken. rg --type typescript -A 5 $'updateProjectDates'Length of output: 81
Script:
#!/bin/bash # Description: Verify the impact of commenting out `updateProjectDates`. # Test: Search for the function usage to ensure no dependencies are broken. rg --type ts -A 5 $'updateProjectDates'Length of output: 1422
utilities/project-factory/src/server/validators/campaignValidators.ts
Outdated
Show resolved
Hide resolved
…tors.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
No description provided.