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

Ashish egov patch 2 #1166

Merged
merged 12 commits into from
Jul 29, 2024
Merged

Ashish egov patch 2 #1166

merged 12 commits into from
Jul 29, 2024

Conversation

ashish-egov
Copy link
Contributor

No description provided.

Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

Walkthrough

The recent updates focus on simplifying the database and application architecture by removing redundant foreign key constraints, modifying Kafka message handling, and enhancing internal function logic. Notably, the migration script cleans up database relationships, while changes in the API and configuration streamline message processing and improve error logging. This evolution enhances maintainability, clarity, and flexibility within the system, paving the way for more efficient campaign mapping operations.

Changes

Files Change Summary
utilities/project-factory/migration/...sql Removed foreign key constraints from eg_cm_campaign_process and eg_cm_resource_activity tables to enhance schema flexibility and integrity.
utilities/project-factory/src/server/api/genericApis.ts Updated createRelatedEntity function to replace produceModifiedMessages with processMapping, renaming the parameter for clarity and changing the underlying processing method.
utilities/project-factory/src/server/config/index.ts Removed KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC from configuration, indicating a shift in messaging architecture related to campaign mapping.
utilities/project-factory/src/server/kafka/Listener.ts Eliminated KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC from listener, simplifying message handling and enhancing error logging for better operational monitoring.
utilities/project-factory/src/server/utils/campaignMappingUtils.ts Renamed messageObject to mappingObject in processMapping function for better clarity, while retaining the original logic and internal checks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant Kafka Listener
    participant Database

    User->>API: Request to create campaign mapping
    API->>Database: Validate and store mapping data
    Database-->>API: Confirmation of data storage
    API->>Kafka Listener: Send mapping data for processing
    Kafka Listener->>Kafka: Produce message to Kafka topic
    Kafka-->>Kafka Listener: Message acknowledgement
    Kafka Listener->>API: Acknowledge message processing
    API-->>User: Confirm campaign mapping created
Loading

🐰 In a world of code, so bright and new,
A rabbit hops in, to share the view.
Constraints are gone, and errors more clear,
With each little change, we cheer and we cheer!
Let's map out our campaigns, let the data flow,
Here’s to our code, let's watch it grow! 🌱✨


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 (3)
utilities/project-factory/migration/main/V20240725155100__remove_constraint_process_details.sql (1)

1-1: Add a more descriptive comment.

The comment should include more details about why the constraints are being removed and any potential impacts.

- -- Migration script to remove the foreign key constraint
+ -- Migration script to remove redundant foreign key constraints from the eg_cm_campaign_process and eg_cm_resource_activity tables.
+ -- This is done to simplify the database schema and improve performance.
utilities/project-factory/src/server/kafka/Listener.ts (2)

79-80: Improve error logging message.

The error logging message should be more descriptive.

- console.log('Error coming for message : ', modifiedMessages);
+ console.error('Error while sending message to Kafka: ', modifiedMessages);

88-88: Improve error logging message.

The error logging message should be more descriptive.

- throwError("COMMON", 400, "KAKFA_ERROR", "Some error occured in kafka");
+ throwError("COMMON", 400, "KAFKA_ERROR", "An error occurred while sending message to Kafka");
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54a22ff and 0ea281d.

Files selected for processing (5)
  • utilities/project-factory/migration/main/V20240725155100__remove_constraint_process_details.sql (1 hunks)
  • utilities/project-factory/src/server/api/genericApis.ts (2 hunks)
  • utilities/project-factory/src/server/config/index.ts (1 hunks)
  • utilities/project-factory/src/server/kafka/Listener.ts (5 hunks)
  • utilities/project-factory/src/server/utils/campaignMappingUtils.ts (1 hunks)
Additional comments not posted (6)
utilities/project-factory/migration/main/V20240725155100__remove_constraint_process_details.sql (2)

2-2: Ensure the constraint name is correct.

Double-check that fk_campaignId is the correct name of the foreign key constraint in the eg_cm_campaign_process table.

Verification successful

The constraint name is correct.

The foreign key constraint fk_campaignId is correctly referenced in the eg_cm_campaign_process table.

  • utilities/project-factory/migration/main/V20240625141100__process_details_ddl.sql: Defines the constraint fk_campaignId.
  • utilities/project-factory/migration/main/V20240725155100__remove_constraint_process_details.sql: Drops the constraint fk_campaignId.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the foreign key constraint name in the eg_cm_campaign_process table.

# Test: Check the constraint name. Expect: The constraint name should be fk_campaignId.
psql -c "\d+ eg_cm_campaign_process"

Length of output: 110


Script:

#!/bin/bash
# Search for the definition of the eg_cm_campaign_process table and its constraints in the codebase.
rg --context 10 'CREATE TABLE eg_cm_campaign_process' 

Length of output: 55


Script:

#!/bin/bash
# List all SQL files and search within them for mentions of the eg_cm_campaign_process table and its constraints.
fd -e sql -x rg 'eg_cm_campaign_process' {}

Length of output: 166


Script:

#!/bin/bash
# Search for the definition of the fk_campaignId constraint in the codebase.
rg 'fk_campaignId'

Length of output: 371


3-3: Ensure the constraint name is correct.

Double-check that eg_cm_resource_activity_resourceDetailsId_fkey is the correct name of the foreign key constraint in the eg_cm_resource_activity table.

utilities/project-factory/src/server/kafka/Listener.ts (1)

Line range hint 29-29:
Remove unused topic from topicNames array.

Ensure that the removed topic is not referenced elsewhere in the code.

Verification successful

Remove unused topic from topicNames array.

The topic KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC is not referenced elsewhere in the codebase, and its removal from the topicNames array does not impact the functionality.

  • topicNames array definition and usages confirm that the removed topic is not indirectly referenced.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removed topic is not referenced elsewhere in the code.

# Test: Search for the removed topic. Expect: No occurrences of the removed topic.
rg --type js 'KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC'

Length of output: 51


Script:

#!/bin/bash
# Description: Verify that the removed topic is not referenced elsewhere in the code.

# Test: Search for the removed topic across all file types and include case-insensitive and partial matches.
rg -i 'KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC'

Length of output: 44


Script:

#!/bin/bash
# Description: Verify that the `topicNames` array does not indirectly reference the removed topic.

# Test: Search for the definition of the `topicNames` array.
rg 'topicNames' -A 3

# Test: Search for usages of the `topicNames` array.
rg 'topicNames'

Length of output: 901

utilities/project-factory/src/server/config/index.ts (1)

58-58: Remove unused Kafka topic.

Ensure that the removed topic is not referenced elsewhere in the code.

Verification successful

The unused Kafka topic KAFKA_UPDATE_RESOURCE_DETAILS_TOPIC is not referenced elsewhere in the codebase. It is safe to remove it.

  • No further occurrences of KAFKA_UPDATE_RESOURCE_DETAILS_TOPIC were found in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removed topic is not referenced elsewhere in the code.

# Test: Search for the removed topic. Expect: No occurrences of the removed topic.
rg --type js 'KAFKA_PROCESS_CAMPAIGN_MAPPING_TOPIC'

Length of output: 51


Script:

#!/bin/bash
# Description: Verify that the removed topic is not referenced elsewhere in the code.

# Test: Search for the removed topic. Expect: No occurrences of the removed topic.
rg --type js 'KAFKA_UPDATE_RESOURCE_DETAILS_TOPIC'

Length of output: 50

utilities/project-factory/src/server/utils/campaignMappingUtils.ts (1)

418-434: LGTM! But verify the function usage in the codebase.

The code changes are approved. The renaming of the parameter from messageObject to mappingObject improves clarity.

However, ensure that all function calls to processMapping match the new parameter name.

Verification successful

Function usage verified and matches the new parameter name.

The call to processMapping correctly uses the updated parameter name mappingObject.

  • utilities/project-factory/src/server/api/genericApis.ts: await processMapping(mappingObject)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `processMapping` match the new parameter name.

# Test: Search for the function usage. Expect: Only occurrences of the new parameter name.
rg --type typescript -A 5 $'processMapping'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify all function calls to `processMapping` match the new parameter name.

# Test: Search for the function usage. Expect: Only occurrences of the new parameter name.
rg 'processMapping' -A 5

Length of output: 2082


Script:

#!/bin/bash
# Description: Verify the parameter name in the call to `processMapping` in `genericApis.ts`.

# Test: Check the parameter name in the call to `processMapping`.
rg 'await processMapping' -A 5 utilities/project-factory/src/server/api/genericApis.ts

Length of output: 214

utilities/project-factory/src/server/api/genericApis.ts (1)

887-888: LGTM! But verify the function usage in the codebase.

The code changes are approved. The renaming of the variable from produceMessage to mappingObject improves clarity.

However, ensure that all function calls to createRelatedEntity match the new variable name.

Verification successful

Verification successful!

All references to createRelatedEntity and the variable mappingObject are consistent and correctly updated in the codebase.

  • The variable mappingObject is used appropriately within the processMapping function and other relevant parts of the code.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createRelatedEntity` match the new variable name.

# Test: Search for the function usage. Expect: Only occurrences of the new variable name.
rg --type typescript -A 5 $'createRelatedEntity'

Length of output: 82


Script:

#!/bin/bash
# Description: Verify all function calls to `createRelatedEntity` match the new variable name.

# Find all TypeScript files and search for the function usage.
fd -e ts -x rg 'createRelatedEntity' {}

Length of output: 297


Script:

#!/bin/bash
# Description: Verify all function calls to `createRelatedEntity` match the new variable name.

# Find all TypeScript files and search for the term `mappingObject` to ensure consistency.
fd -e ts -x rg 'mappingObject' {}

Length of output: 1656

utilities/project-factory/src/server/kafka/Listener.ts Outdated Show resolved Hide resolved
@jagankumar-egov jagankumar-egov merged commit 4acfd01 into campaign Jul 29, 2024
3 of 4 checks passed
@jagankumar-egov jagankumar-egov deleted the ashish-egov-patch-2 branch July 29, 2024 05:38
Bhavya-egov pushed a commit that referenced this pull request Aug 12, 2024
* Update Listener.ts

* added new branch

* Update Listener.ts

* fixed mapping kafka error

* mapping kafka fixed

* fix kafka

* fix kafka

* Removing foreign key constraint

* Update publishProjectFactory.yml
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