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 6 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 a new method to retrieve user details by email and name.
  • 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 aims to enhance the project by upgrading the Java base image from version 17 to 21, adding a new Maven repository for snapshot dependencies, and updating critical dependencies. Additionally, there have been significant modifications to the repository and service layers to support improved data retrieval with the introduction of UserCASDetailsEntityView. Tests are also updated to incorporate the necessary configurations.

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.
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/.../repository/CustomUserCASDetailsEntityRepository.java Introduced interface CustomUserCASDetailsEntityRepository with method findByInvestorEmailAndName.
src/main/java/com/.../repository/impl/CustomUserCASDetailsEntityRepositoryImpl.java Implemented the findByInvestorEmailAndName method.
src/main/java/com/.../repository/UserCASDetailsEntityRepository.java Extended UserCASDetailsEntityRepository to include CustomUserCASDetailsEntityRepository.
src/main/java/com/.../service/PortfolioService.java Updated method parameters and references from UserCASDetailsEntity to UserCASDetailsEntityView. Added comments for future changes.
src/main/java/com/.../service/UserCASDetailsService.java Changed return type of findByInvestorEmailAndName from UserCASDetailsEntity to UserCASDetailsEntityView.
src/test/java/com/.../repository/SchemaValidationPostgresTest.java Added import for BlazePersistenceConfiguration and included it in the test class using @Import annotation.

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

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

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

1 participant