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

feat : using blaze MultiSelect View #363

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

rajadilipkolli
Copy link
Owner

@rajadilipkolli rajadilipkolli commented Jun 10, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new entity views for InvestorInfo, UserCASDetails, UserFolioDetails, UserSchemeDetails, and UserTransactionDetails, improving data retrieval and manipulation.
  • Enhancements

    • Updated base image to Java 21 for improved performance and compatibility.
    • Added a new Maven repository for snapshot dependencies.
    • Updated Spring Boot to version 3.3.1 and Blaze-Persistence to version 1.6.12-SNAPSHOT.
  • Refactor

    • Replaced UserCASDetailsEntity with UserCASDetailsEntityView in service and repository methods for better entity management.
  • Tests

    • Enhanced schema validation tests with Blaze-Persistence configuration.

@rajadilipkolli rajadilipkolli self-assigned this Jun 10, 2024
Copy link
Contributor

coderabbitai bot commented Jun 10, 2024

Walkthrough

This update enhances the project by upgrading the Java base image from version 17 to 21, adding a Maven repository for snapshot dependencies, and updating critical libraries. New entity views for user details improve data retrieval capabilities. Tests have also been updated to integrate necessary configurations, ensuring a smoother development experience and better alignment with the latest changes.

Changes

Files Change Summary
.gitpod.yml Updated the base image from gitpod/workspace-java-17 to gitpod/workspace-java-21.
build.gradle Added https://oss.sonatype.org/content/repositories/snapshots/ Maven repository to both buildscript and repositories sections, and included new Blaze Persistence dependencies.
gradle.properties Updated spring_boot_version from 3.2.5 to 3.3.1 and blaze_persistence_version from 1.6.11 to 1.6.12-SNAPSHOT.
src/main/java/com/.../config/db/BlazePersistenceConfiguration.java Introduced BlazePersistenceConfiguration class to set up Blaze Persistence integration with Spring.
src/main/java/com/.../models/entityviews/*.java Added new entity view interfaces for InvestorInfo, UserCASDetails, UserFolioDetails, UserSchemeDetails, and UserTransactionDetails, enhancing data retrieval capabilities.
src/test/java/com/.../repository/SchemaValidationPostgresTest.java Added import for BlazePersistenceConfiguration and included it in the test class with @Import annotation.
src/test/java/com/.../archunit/ModelRulesTest.java Removed an extraneous semicolon within the test method.

Poem

In the world of code, a hop so grand,
From Java 17 to 21, we’ll take our stand. 🌿
Dependencies now fresh and bright, ✨
With new views, our data's in sight. 🔍
Blaze persists in a snapshot flight. 🚀
In tests, we fine-tune the light,
A rabbit's joy in each byte! 🐇❤️


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: 2

Outside diff range and nitpick comments (1)
src/main/java/com/learning/mfscreener/repository/CustomUserCASDetailsEntityRepository.java (1)

5-7: Consider adding Javadoc comments to the findByInvestorEmailAndName method.

Providing documentation can help other developers understand the purpose of the method and its parameters more clearly.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58d5c14 and 3cae2d5.

Files selected for processing (5)
  • .gitpod.yml (1 hunks)
  • gradle.properties (1 hunks)
  • src/main/java/com/learning/mfscreener/repository/CustomUserCASDetailsEntityRepository.java (1 hunks)
  • src/main/java/com/learning/mfscreener/repository/CustomUserCASDetailsEntityRepositoryImpl.java (1 hunks)
  • src/main/java/com/learning/mfscreener/repository/UserCASDetailsEntityRepository.java (1 hunks)
Files skipped from review due to trivial changes (2)
  • .gitpod.yml
  • gradle.properties

Comment on lines 10 to 38
public class CustomUserCASDetailsEntityRepositoryImpl implements CustomUserCASDetailsEntityRepository {

private final EntityManager entityManager;

private final CriteriaBuilderFactory criteriaBuilderFactory;

private final EntityViewManager entityViewManager;

public CustomUserCASDetailsEntityRepositoryImpl(
EntityManager entityManager,
CriteriaBuilderFactory criteriaBuilderFactory,
EntityViewManager entityViewManager) {
this.entityManager = entityManager;
this.criteriaBuilderFactory = criteriaBuilderFactory;
this.entityViewManager = entityViewManager;
}

@Override
public UserCASDetailsEntityView findByInvestorEmailAndName(String email, String name) {
return entityViewManager
.applySetting(
EntityViewSetting.create(UserCASDetailsEntityView.class),
criteriaBuilderFactory.create(entityManager, UserCASDetailsEntity.class))
.where("investorInfoEntity.email")
.eq(email)
.where("investorInfoEntity.name")
.eq(name) // Adding condition for the name
.getSingleResult();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add exception handling and documentation to findByInvestorEmailAndName.

Handling exceptions and providing documentation will improve the robustness and maintainability of this method.

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 3cae2d5 and 610cd36.

Files selected for processing (5)
  • build.gradle (2 hunks)
  • gradle.properties (1 hunks)
  • src/main/java/com/learning/mfscreener/repository/UserCASDetailsEntityRepository.java (2 hunks)
  • src/main/java/com/learning/mfscreener/service/PortfolioService.java (4 hunks)
  • src/main/java/com/learning/mfscreener/service/UserCASDetailsService.java (2 hunks)
Files skipped from review due to trivial changes (1)
  • build.gradle
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/learning/mfscreener/repository/UserCASDetailsEntityRepository.java
Additional comments not posted (4)
gradle.properties (2)

11-11: Update to Spring Boot version 3.2.6 approved.


12-12: Update to Blaze Persistence version 1.6.12-SNAPSHOT approved.

src/main/java/com/learning/mfscreener/service/UserCASDetailsService.java (2)

5-5: Import of UserCASDetailsEntityView is appropriate for the new method implementation.


29-29: Method findByInvestorEmailAndName correctly uses UserCASDetailsEntityView. Consider adding error handling for potential null values or exceptions.

@@ -133,45 +134,46 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) {
long userTransactionCount = portfolioServiceHelper.countTransactionsByUserFolioDTOList(inputUserFolioDTOList);
List<UserTransactionDetailsEntity> userTransactionDetailsEntityList =
this.userTransactionDetailsService.findAllTransactionsByEmailAndName(email, name);
UserCASDetailsEntity userCASDetailsEntity = userCASDetailsService.findByInvestorEmailAndName(email, name);
UserCASDetailsEntityView userCASDetailsEntityView =
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates to use UserCASDetailsEntityView are consistent with PR objectives. Ensure completion of TODO items.

Would you like assistance in completing the TODO items mentioned in the code?

Also applies to: 146-146, 153-153, 164-164, 176-176, 338-338

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai, please help me with fixing TODO as per above comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajadilipkolli, I can help you address the TODO items in your code. Here are the suggested changes:

1. Adding Folios to UserCASDetailsEntityView

You have a TODO comment where you need to add folio entities to UserCASDetailsEntityView. Here's how you can do it:

// In the processNewFolios method
userFolioDTOList.forEach(userFolioDTO -> {
    String folio = userFolioDTO.folio();
    if (!existingFolioNumbers.contains(folio)) {
        LOGGER.info("New folio: {} created that is not present in the database", folio);
        userCASDetailsEntityView.addFolioEntity(
            casDetailsMapper.mapUserFolioDTOToUserFolioDetailsEntity(userFolioDTO));
        folioCounter.incrementAndGet();
        int newTransactions = userFolioDTO.schemes().stream()
                .map(UserSchemeDTO::transactions)
                .flatMap(List::stream)
                .toList()
                .size();
        transactionsCounter.addAndGet(newTransactions);
    }
});

2. Bulk Insert for Transactions

For the second TODO, you mentioned converting to bulk insert. This typically involves collecting all entities and using a method that supports batch processing to minimize database hits. Here's a conceptual change:

// Collect all transactions to be inserted
List<UserTransactionDetailsEntity> transactionsToInsert = new ArrayList<>();
userSchemaTransactionMap.forEach((isinFromRequest, requestTransactions) -> {
    List<UserTransactionDetailsEntity> dbTransactions =
            userSchemaTransactionMapFromDB.getOrDefault(isinFromRequest, List.of());
    if (requestTransactions.size() != dbTransactions.size()) {
        requestTransactions.forEach(userTransactionDTO -> {
            LocalDate newTransactionDate = userTransactionDTO.date();
            if (!transactionDateListDB.contains(newTransactionDate)) {
                UserTransactionDetailsEntity userTransactionDetailsEntity =
                        casDetailsMapper.transactionDTOToTransactionEntity(userTransactionDTO);
                transactionsToInsert.add(userTransactionDetailsEntity);
            }
        });
    }
});

// Use a method to bulk insert
userTransactionDetailsService.bulkInsert(transactionsToInsert);

Make sure to implement or update the bulkInsert method in your UserTransactionDetailsService to handle the batch insert operation efficiently.

These changes should help you complete the TODO items and improve the efficiency of your application. Let me know if you need further assistance!

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 610cd36 and 8f7715a.

Files selected for processing (3)
  • build.gradle (2 hunks)
  • src/main/java/com/learning/mfscreener/repository/impl/CustomUserCASDetailsEntityRepositoryImpl.java (1 hunks)
  • src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • build.gradle
Additional comments not posted (3)
src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java (2)

5-5: The import of BlazePersistenceConfiguration is correctly added to support the configuration needed for the tests.


18-18: Correct use of the @Import annotation to ensure BlazePersistenceConfiguration is part of the Spring context for testing.

src/main/java/com/learning/mfscreener/repository/impl/CustomUserCASDetailsEntityRepositoryImpl.java (1)

1-40: New class CustomUserCASDetailsEntityRepositoryImpl correctly implements CustomUserCASDetailsEntityRepository. Dependency injection is properly used, and the method findByInvestorEmailAndName correctly utilizes Blaze-Persistence for querying.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8f7715a and 9781baa.

Files selected for processing (2)
  • build.gradle (2 hunks)
  • gradle.properties (1 hunks)
Files skipped from review due to trivial changes (2)
  • build.gradle
  • gradle.properties

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9781baa and c6966e8.

Files selected for processing (2)
  • build.gradle (1 hunks)
  • src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java (2 hunks)
Additional comments not posted (3)
src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java (2)

5-5: Confirm the necessity of the new import.

Ensure that BlazePersistenceConfiguration is required for the functionality being tested in this file.


14-14: Confirm the necessity of the annotation change.

Ensure that including BlazePersistenceConfiguration in the @Import annotation is necessary and does not introduce unintended side effects.

build.gradle (1)

6-6: Confirm the necessity of the new Maven repository.

Ensure that adding the snapshot repository from Sonatype is necessary and does not introduce potential issues with dependency management.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c6966e8 and d49c85a.

Files selected for processing (9)
  • build.gradle (2 hunks)
  • src/main/java/com/learning/mfscreener/config/db/BlazePersistenceConfiguration.java (1 hunks)
  • src/main/java/com/learning/mfscreener/models/entityviews/InvestorInfoEntityView.java (1 hunks)
  • src/main/java/com/learning/mfscreener/models/entityviews/UserCASDetailsEntityView.java (1 hunks)
  • src/main/java/com/learning/mfscreener/models/entityviews/UserFolioDetailsEntityView.java (1 hunks)
  • src/main/java/com/learning/mfscreener/models/entityviews/UserSchemeDetailsEntityView.java (1 hunks)
  • src/main/java/com/learning/mfscreener/models/entityviews/UserTransactionDetailsEntityView.java (1 hunks)
  • src/test/java/com/learning/mfscreener/archunit/ModelRulesTest.java (1 hunks)
  • src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/test/java/com/learning/mfscreener/archunit/ModelRulesTest.java
Files skipped from review as they are similar to previous changes (2)
  • build.gradle
  • src/test/java/com/learning/mfscreener/repository/SchemaValidationPostgresTest.java
Additional comments not posted (30)
src/main/java/com/learning/mfscreener/models/entityviews/InvestorInfoEntityView.java (1)

1-31: LGTM! Consider adding method documentation.

The code changes are approved. Adding Javadoc comments to the methods would improve readability and maintainability.

src/main/java/com/learning/mfscreener/models/entityviews/UserTransactionDetailsEntityView.java (1)

1-40: LGTM! Consider adding method documentation.

The code changes are approved. Adding Javadoc comments to the methods would improve readability and maintainability.

src/main/java/com/learning/mfscreener/models/entityviews/UserFolioDetailsEntityView.java (1)

1-37: LGTM! Consider adding method documentation.

The code changes are approved. Adding Javadoc comments to the methods would improve readability and maintainability.

src/main/java/com/learning/mfscreener/models/entityviews/UserCASDetailsEntityView.java (9)

18-18: LGTM!

The method getCreatedBy is correctly defined.


20-20: LGTM!

The method getCreatedDate is correctly defined.


22-22: LGTM!

The method getLastModifiedBy is correctly defined.


24-24: LGTM!

The method getLastModifiedDate is correctly defined.


26-27: LGTM!

The method getId is correctly defined and annotated.


29-29: LGTM!

The method getCasTypeEnum is correctly defined.


31-31: LGTM!

The method getFileTypeEnum is correctly defined.


33-33: LGTM!

The method getInvestorInfoEntity is correctly defined.


35-36: LGTM!

The method getFolioEntities is correctly defined and annotated.

src/main/java/com/learning/mfscreener/models/entityviews/UserSchemeDetailsEntityView.java (16)

16-16: LGTM!

The method getCreatedBy is correctly defined.


18-18: LGTM!

The method getCreatedDate is correctly defined.


20-20: LGTM!

The method getLastModifiedBy is correctly defined.


22-22: LGTM!

The method getLastModifiedDate is correctly defined.


24-25: LGTM!

The method getId is correctly defined and annotated.


27-27: LGTM!

The method getScheme is correctly defined.


29-29: LGTM!

The method getIsin is correctly defined.


31-31: LGTM!

The method getAdvisor is correctly defined.


33-33: LGTM!

The method getRtaCode is correctly defined.


35-35: LGTM!

The method getRta is correctly defined.


37-37: LGTM!

The method getType is correctly defined.


39-39: LGTM!

The method getAmfi is correctly defined.


41-41: LGTM!

The method getMyopen is correctly defined.


43-43: LGTM!

The method getClose is correctly defined.


45-45: LGTM!

The method getCloseCalculated is correctly defined.


47-48: LGTM!

The method getTransactionEntities is correctly defined and annotated.

src/main/java/com/learning/mfscreener/config/db/BlazePersistenceConfiguration.java (2)

42-48: LGTM!

The method createCriteriaBuilderFactory is correctly defined and annotated.


50-56: LGTM!

The method createEntityViewManager is correctly defined and annotated.

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