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

User usage column changes #1293

Merged
merged 8 commits into from
Aug 16, 2024
Merged

Conversation

ashish-egov
Copy link
Contributor

No description provided.

* Update campaignApis.ts

* Update campaignUtils.ts (#1279)
#1285)

feat: Add parentId and isActive columns to eg_cm_campaign_details, remove unique constraint on campaignName
* Update campaignApis.ts (#1278)

* Update campaignApis.ts

* Update campaignUtils.ts (#1279)

* feat: Add parentId and isActive columns to eg_cm_campaign_details, remove unique constraint on campaignName

* Feat : adding usage column in user create
* feat: Add parentId and isActive columns to eg_cm_campaign_details, remove unique constraint on campaignName

* Fix : user mapping
Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Commits

Files that changed from the base of the PR and between 91068a7 and 3c49d7a.

Walkthrough

Walkthrough

The 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

Files Change Summary
.github/workflows/publishProjectFactory.yml Updated CI triggers to focus on the campaign-for-test branch.
utilities/project-factory/migration/main/*.sql Added and removed columns in eg_cm_campaign_details for better hierarchy and status tracking, with updated naming conventions.
utilities/project-factory/src/server/api/campaignApis.ts Modified handleResouceDetailsError for improved data structure when processing activities.
utilities/project-factory/src/server/config/constants.ts Introduced PARENT_CAMPAIGN_ERROR for enhanced error messaging.
utilities/project-factory/src/server/config/createAndSearch.ts Updated column identifiers for unique and active user management.
utilities/project-factory/src/server/config/models/*.ts Updated schemas to remove and add properties for campaign management (e.g., removed "changeDates" from actions).
utilities/project-factory/src/server/kafka/Listener.ts Streamlined logging sequence for improved clarity and performance.
utilities/project-factory/src/server/utils/*.ts Modified user credential handling, introduced new campaign management functions, and commented out obsolete functions.
utilities/project-factory/src/server/validators/*.ts Enhanced validation logic, added functions for parent campaign checks, and refined error handling for campaign names.

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
Loading

Poem

🐇 In a garden of code, where changes bloom bright,
New paths for campaigns, oh what a delight!
With constants and errors now clearer to see,
Our project hops forward, as happy as can be!
So let us rejoice with a leap and a cheer,
For a brighter tomorrow is finally here! 🌼


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 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: 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 column parentId is indexed if necessary.

Adding the parentId column as a character varying(128) is fine, but consider indexing it if it will be used in queries to improve performance.


4-5: Consider default values for the isActive column.

Adding the isActive column as a boolean without a default value may lead to NULL 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 the parentid column if necessary.

Adding the parentid column as a character varying(128) is fine, but consider indexing it if it will be used in queries to improve performance.


13-13: Consider default values for the isactive column.

Adding the isactive column as a boolean without a default value may lead to NULL 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 to changeDates in the codebase.

The removal of changeDates from the action enum requires updating the following parts of the codebase where changeDates is still referenced:

  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js: changeDatesEnabled is set to true.
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js: isChangeDates is used, and payloadData.action is assigned "changeDates".

These references need to be revised to ensure consistency with the updated enum values.

Analysis chain

Removal of changeDates from the action enum.

The removal of changeDates limits valid actions to create and draft.

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

Commits

Files that changed from the base of the PR and between 529a1bb and 91068a7.

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 the campaignName 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 for parentId.

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 for isActive.

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 of isActive 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 Verified

The 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 of isActive and parentId 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 of PARENT_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 in validateCampaign.

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, and activeColumnName 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 in activityObject Construction.

The change encapsulates request.body.Activities in an object with the Activities key. This improves data structure consistency. Verify that all downstream functions handle this new structure correctly.

Verification successful

Verification Complete: activityObject Structure is Consistent

The activityObject is correctly structured and passed to produceModifiedMessages, 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 of activityObject.
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 the validateRootBoundaryWithParent 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 in validateDraftProjectCampaignMissingFields.

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 the validateParent 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 of parentId 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 the isActive 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 out updateProjectDates.

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

@jagankumar-egov jagankumar-egov merged commit 0a419be into campaign Aug 16, 2024
3 of 4 checks passed
@jagankumar-egov jagankumar-egov deleted the user-usage-column-changes branch August 16, 2024 07:46
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