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

HLM-5701-create-microplan changes #741

Conversation

devdatta-egov
Copy link
Collaborator

@devdatta-egov devdatta-egov commented May 16, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration for the "Plan Create" endpoint.
    • Enhanced the resource estimation service with additional plan creation capabilities.
  • Improvements

    • Updated various methods to utilize PlanConfigurationRequest for better consistency and flexibility in handling plan configurations.
  • Bug Fixes

    • Added error handling constants for improved error reporting and debugging.

These changes aim to improve the efficiency and reliability of the resource estimation process.

Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

The recent updates enhance the health-services resource-estimation-service by introducing a new endpoint for plan creation and refactoring several classes to use PlanConfigurationRequest instead of PlanConfiguration. Key changes include updating method signatures, adding new utility methods in PlanUtil, and configuring the new endpoint in application.properties.

Changes

File Path Change Summary
.../Configuration.java Added planCreateEndPoint variable with @Value annotation.
.../ServiceConstants.java Added constants for BOUNDARY_CODE and ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY.
.../ExcelParser.java Updated to use PlanConfigurationRequest, added PlanUtil import, and called planUtil.create.
.../FileParser.java Changed parseFileData method signature to accept PlanConfigurationRequest.
.../GeoJsonParser.java Modified parseFileData method to use PlanConfigurationRequest.
.../ResourceEstimationService.java Updated estimateResources to pass planConfigurationRequest.
.../ShapeFileParser.java Changed parseFileData to use PlanConfigurationRequest, retrieved PlanConfiguration.
.../CalculationUtil.java Added PlanUtil field, constructor, and updated calculateResources method.
.../PlanUtil.java Added methods for creating plans and handling boundary code values.
.../application.properties Added egov.plan.create.endpoint configuration.

🐇
Code changes in the springtime air,
New endpoints here and there,
Refactoring done with care,
Configuration requests to share,
Plan creation everywhere!
🌸


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@Priyanka-eGov
Copy link
Collaborator

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 17, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0a86d74 and 3b656c3.
Files selected for processing (10)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/config/Configuration.java (1 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/config/ServiceConstants.java (1 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ExcelParser.java (8 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/service/FileParser.java (1 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java (3 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ResourceEstimationService.java (1 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java (3 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/util/CalculationUtil.java (2 hunks)
  • health-services/resource-estimation-service/src/main/java/org/egov/processor/util/PlanUtil.java (1 hunks)
  • health-services/resource-estimation-service/src/main/resources/application.properties (1 hunks)
Files skipped from review due to trivial changes (1)
  • health-services/resource-estimation-service/src/main/resources/application.properties
Additional comments not posted (12)
health-services/resource-estimation-service/src/main/java/org/egov/processor/service/FileParser.java (1)

11-11: Ensure all implementations of FileParser interface are updated to handle PlanConfigurationRequest.

Verification successful

All implementations of FileParser interface are updated

The parseFileData method in all implementations of the FileParser interface (ShapeFileParser, GeoJsonParser, and ExcelParser) has been updated to handle PlanConfigurationRequest.

  • ShapeFileParser: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId)
  • GeoJsonParser: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId)
  • ExcelParser: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId)
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all implementations of `FileParser` interface handle the new method signature.

# Test: Search for implementations of `FileParser`. Expect: All implementations should use the new method signature.
rg --type java $'implements FileParser'

Length of output: 505



Script:

#!/bin/bash
# Description: Verify that the `parseFileData` method in each implementation of `FileParser` matches the new method signature.

# Search for the `parseFileData` method in ShapeFileParser
rg --type java 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java

# Search for the `parseFileData` method in GeoJsonParser
rg --type java 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java

# Search for the `parseFileData` method in ExcelParser
rg --type java 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ExcelParser.java

Length of output: 719

health-services/resource-estimation-service/src/main/java/org/egov/processor/config/ServiceConstants.java (1)

39-40: Ensure new constants BOUNDARY_CODE and ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY are utilized appropriately in the codebase.

Verification successful

Constants Utilization Verified

The new constants BOUNDARY_CODE and ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY are appropriately utilized in the codebase.

  • ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY is used in a logging statement in PlanUtil.java.
  • BOUNDARY_CODE is used in a method call in PlanUtil.java.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of new constants in the codebase.

# Test: Search for the usage of `BOUNDARY_CODE` and `ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY`. Expect: They should be used in relevant logic.
rg --type java $'BOUNDARY_CODE|ERROR_WHILE_FETCHING_FROM_PLAN_SERVICE_FOR_LOCALITY'

Length of output: 2189

health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ResourceEstimationService.java (1)

55-55: Ensure the new method signature of estimateResources is correctly used in the codebase.

Verification successful

Verification of estimateResources Method Signature Usage

The method estimateResources is correctly used with PlanConfigurationRequest in the codebase.

  • Method Definition: ResourceEstimationService.java defines estimateResources with PlanConfigurationRequest.
  • Method Call: PlanConsumer.java calls estimateResources with a PlanConfigurationRequest object.

Both instances confirm the correct usage of the new method signature.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the new method signature of `estimateResources`.

# Test: Search for the usage of `estimateResources`. Expect: It should be used with `PlanConfigurationRequest`.
rg --type java $'estimateResources'

Length of output: 425



Script:

#!/bin/bash
# Description: Verify the method call of `estimateResources` in `PlanConsumer.java`.

# Extract the relevant lines around the method call to ensure it uses `PlanConfigurationRequest`.
rg -A 5 -B 5 'resourceEstimationService.estimateResources' health-services/resource-estimation-service/src/main/java/org/egov/processor/kafka/PlanConsumer.java

Length of output: 889

health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java (1)

55-56: Ensure the new method signature of parseFileData in GeoJsonParser is correctly used in the codebase.

Verification successful

The new method signature of parseFileData in GeoJsonParser is correctly used in the codebase.

  • ResourceEstimationService.java uses parseFileData with PlanConfigurationRequest and String for fileStoreId.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the new method signature of `parseFileData` in `GeoJsonParser`.

# Test: Search for the usage of `parseFileData`. Expect: It should be used with `PlanConfigurationRequest`.
rg --type java $'parseFileData'

Length of output: 1259



Script:

#!/bin/bash
# Extract the relevant lines from ResourceEstimationService.java to verify the method usage.
rg --type java -A 5 -B 5 'parser.parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ResourceEstimationService.java

Length of output: 631

health-services/resource-estimation-service/src/main/java/org/egov/processor/util/PlanUtil.java (1)

43-54: Ensure new methods create, buildPlanRequest, and getBoundaryCodeValue in PlanUtil are utilized appropriately in the codebase.

Verification successful

Verification of New Methods in PlanUtil

The new methods create, buildPlanRequest, and getBoundaryCodeValue in PlanUtil are utilized appropriately in the codebase:

  • create Method:

    • Used in CalculationUtil and ExcelParser.
  • buildPlanRequest Method:

    • Utilized within the create method in PlanUtil.
  • getBoundaryCodeValue Method:

    • Utilized within the buildPlanRequest method in PlanUtil.

These usages confirm that the new methods are integrated into the relevant logic within the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of new methods in `PlanUtil`.

# Test: Search for the usage of `create`, `buildPlanRequest`, and `getBoundaryCodeValue`. Expect: They should be used in relevant logic.
rg --type java $'create|buildPlanRequest|getBoundaryCodeValue'

Length of output: 267292

health-services/resource-estimation-service/src/main/java/org/egov/processor/util/CalculationUtil.java (1)

73-73: Ensure the new method signature of calculateResources in CalculationUtil is correctly used in the codebase.

Verification successful

The verification confirms that the new method signature of calculateResources in CalculationUtil is correctly used in the codebase.

  • Both GeoJsonParser.java and ShapeFileParser.java call calculateResources with the parameters jsonNode, planConfigurationRequest, resultMap, mappedValues, and assumptionValueMap, which aligns with the new method signature.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the new method signature of `calculateResources` in `CalculationUtil`.

# Test: Search for the usage of `calculateResources`. Expect: It should be used with `PlanConfigurationRequest`.
rg --type java $'calculateResources'

Length of output: 738



Script:

#!/bin/bash
# Extract the lines containing the method calls to `calculateResources` in `GeoJsonParser.java` and `ShapeFileParser.java` to verify the parameters.

# Extract method call in GeoJsonParser.java
rg --type java --context 5 'calculateResources' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java

# Extract method call in ShapeFileParser.java
rg --type java --context 5 'calculateResources' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java

Length of output: 1624

health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java (1)

58-58: Ensure the new method signature of parseFileData in ShapeFileParser is correctly used in the codebase.

Verification successful

The rg command output shows multiple instances of parseFileData usage across different files. We need to verify each instance to ensure the method is used with PlanConfigurationRequest and String fileStoreId.

Instances to Verify:

  1. ResourceEstimationService.java
  2. ShapeFileParser.java
  3. FileParser.java
  4. GeoJsonParser.java
  5. ExcelParser.java

Let's generate a script to extract the relevant lines from these files to verify the method usage.


The output confirms that the new method signature of parseFileData in ShapeFileParser is correctly used across the codebase. Specifically, the method is consistently used with PlanConfigurationRequest and String fileStoreId parameters in the following files:

  • ResourceEstimationService.java
  • ShapeFileParser.java
  • FileParser.java
  • GeoJsonParser.java
  • ExcelParser.java

Verified Instances:

  • ResourceEstimationService.java: parser.parseFileData(planConfigurationRequest, planConfiguration.getFiles().get(0).getFilestoreId());
  • ShapeFileParser.java: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId) {
  • FileParser.java: Object parseFileData(PlanConfigurationRequest planConfigurationRequest , String fileStoreId);
  • GeoJsonParser.java: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId) {
  • ExcelParser.java: public Object parseFileData(PlanConfigurationRequest planConfigurationRequest, String fileStoreId) {

No discrepancies were found in the method usage.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the new method signature of `parseFileData` in `ShapeFileParser`.

# Test: Search for the usage of `parseFileData`. Expect: It should be used with `PlanConfigurationRequest`.
rg --type java $'parseFileData'

Length of output: 1259



Script:

#!/bin/bash
# Extract lines where `parseFileData` is used in the specified files to verify the method signature.

# Files to check
files=(
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/web/controllers/FileController.java"
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ResourceEstimationService.java"
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java"
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/service/FileParser.java"
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java"
  "health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ExcelParser.java"
)

# Loop through files and extract relevant lines
for file in "${files[@]}"; do
  echo "File: $file"
  rg 'parseFileData' "$file"
  echo
done

Length of output: 3632

health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ExcelParser.java (5)

25-28: Added imports for PlanUtil and PlanConfigurationRequest.


47-54: Introduced a new field planUtil and updated the constructor to initialize it.


Line range hint 65-75: Updated parseFileData method to accept PlanConfigurationRequest instead of PlanConfiguration. Ensure that all calls to this method are updated to pass the new parameter type.

Verification successful

Verification of parseFileData Method Calls

The verification process confirms that all instances of the parseFileData method have been updated to use the new parameter type PlanConfigurationRequest. Here are the findings:

  • FileController.java: The method call is commented out, so no update is needed.
  • ShapeFileParser.java: The method signature is correctly updated.
  • GeoJsonParser.java: The method signature is correctly updated.
  • ResourceEstimationService.java: The method call is correctly updated.
  • FileParser.java: The interface method signature is correctly updated.
  • ExcelParser.java: The method signature is correctly updated.

No further action is required as all instances are consistent with the new parameter type.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all calls to `parseFileData` are updated.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type java $'parseFileData'

Length of output: 1259



Script:

#!/bin/bash
# Extract lines around the method calls to verify the parameter type

# FileController.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/web/controllers/FileController.java

# ShapeFileParser.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ShapeFileParser.java

# GeoJsonParser.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/GeoJsonParser.java

# ResourceEstimationService.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ResourceEstimationService.java

# FileParser.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/FileParser.java

# ExcelParser.java
rg -A 5 -B 5 'parseFileData' health-services/resource-estimation-service/src/main/java/org/egov/processor/service/ExcelParser.java

Length of output: 4201


Line range hint 85-97: Updated processExcelFile to use PlanConfigurationRequest. The method now correctly extracts PlanConfiguration from the request object. This change aligns with the PR's objective to integrate PlanConfigurationRequest.


Line range hint 117-147: Refactored processRows to use PlanConfigurationRequest. Added a call to planUtil.create, which is a significant change as it integrates the creation of plans into the row processing logic. Ensure that the integration of planUtil.create is thoroughly tested, especially since it involves complex data manipulations.

@Priyanka-eGov Priyanka-eGov merged commit 24a9175 into HLM-5118-resource-estimation-service May 22, 2024
2 checks passed
@Priyanka-eGov Priyanka-eGov deleted the HLM-5701-create-microplan-resource branch May 22, 2024 08:28
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.

None yet

2 participants