-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore: refactor crud to custom repository #38134
Conversation
…refactor-crud-to-custom-repository
WalkthroughThe changes in this pull request involve significant modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java (3)
302-306
: Consider batch processing for findByIdIn method.For better performance with large ID lists, consider implementing batch processing.
public Flux<Application> findByIdIn(List<String> ids) { + // Process in batches of 100 + return Flux.fromIterable(ids) + .buffer(100) + .flatMap(batch -> { + final BridgeQuery<Application> q = Bridge.in(Application.Fields.id, batch); + return queryBuilder().criteria(q).all(); + }); }
333-338
: Consider adding an index for exportWithConfiguration queries.The findByIdAndExportWithConfiguration method would benefit from an index on (id, exportWithConfiguration).
327-331
: Review performance impact of countByDeletedAtNull.For large datasets, counting all non-deleted applications might be expensive. Consider:
- Caching the count
- Using a counter collection
- Maintaining a running count
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/ApplicationRepositoryCE.java
(1 hunks)app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCE.java
(1 hunks)app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java
(1 hunks)
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/ApplicationRepositoryCE.java (1)
12-12
: LGTM! Clean interface refactoring.
The interface is now more focused with a single method returning IdOnly projection, which is more efficient for workspace-related queries.
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCE.java (1)
84-95
: Verify transaction support for the new repository methods.
As this PR aims to enhance transaction support in PostgreSQL, we should verify that these methods work correctly within transactions.
✅ Verification successful
Let me gather more information about the transaction configuration and repository setup.
Let me check the repository configuration and transaction support more specifically.
Let me try a different approach to verify the repository configuration and transaction support.
Transaction support is properly configured for the repository methods
The repository is built on Spring's reactive MongoDB infrastructure with proper transaction support:
- Extends
BaseRepository
which inherits fromReactiveMongoRepository
ReactiveMongoTransactionManager
is configured inMongoConfig
- Repository implementation uses Spring's reactive transaction management
The new repository methods will automatically participate in transactions when called from transactional service methods.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for transaction-related annotations or configurations
rg -l "@Transactional|TransactionConfiguration" --type java
# Look for transaction manager configurations
rg "TransactionManager|transaction-manager" --type xml --type java
Length of output: 1110
Script:
#!/bin/bash
# Check repository configuration and inheritance
ast-grep --pattern 'interface CustomApplicationRepositoryCE extends $$$'
# Check if the repository is reactive
ast-grep --pattern 'interface $_ extends ReactiveCrudRepository<$$$>'
# Look for transaction configuration in application properties
rg "spring.data.(mongodb|postgresql).transactionEnabled" --type properties --type yml
# Check for reactive repository configuration
rg "EnableReactiveMongoRepositories|EnableR2dbcRepositories" --type java
Length of output: 73399
Script:
#!/bin/bash
# Check repository configuration and inheritance
ast-grep --pattern 'interface CustomApplicationRepositoryCE extends $_'
# Check if the repository implementation has transaction annotations
rg "@Transactional" --type java -A 2 -B 2 app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/
# Look for repository implementation class
rg "class.*implements.*CustomApplicationRepositoryCE" --type java
Length of output: 258
Script:
#!/bin/bash
# Search for repository class and interface with more context
rg -l "CustomApplicationRepositoryCE" --type java
# Look for reactive repository configuration
rg "ReactiveMongoRepository|ReactiveCrudRepository" --type java -A 2 -B 2
# Check for transaction configuration in MongoDB config
rg "ReactiveMongoTransactionManager|@EnableTransactionManagement" --type java -A 2 -B 2
Length of output: 13380
## Description As part of transaction support in PG, we are moving from using the jpa methods for database operations. This PR is refactoring the code to use custom repository class for `ApplicationRepository` from the default CrudRepository. ## Automation /ok-to-test tags="@tag.ImportExport" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12298562052> > Commit: 72d6d37 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12298562052&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.ImportExport` > Spec: > <hr>Thu, 12 Dec 2024 15:00:11 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new methods for retrieving applications by ID, workspace ID, and cloned application ID. - Added functionality to count applications by workspace ID and deletion status. - Enhanced export options for applications. - **Bug Fixes** - Simplified access to applications by removing permission requirements in certain methods. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
As part of transaction support in PG, we are moving from using the jpa methods for database operations. This PR is refactoring the code to use custom repository class for
ApplicationRepository
from the default CrudRepository.Automation
/ok-to-test tags="@tag.ImportExport"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12298562052
Commit: 72d6d37
Cypress dashboard.
Tags:
@tag.ImportExport
Spec:
Thu, 12 Dec 2024 15:00:11 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes