chore: refactor crud methods (#38158)
## 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 DatasourceStorageRepository 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/12406578294> > Commit: c7efa6354d2cc1982121eeeab84ac15f1d400e9a > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12406578294&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.ImportExport` > Spec: > <hr>Thu, 19 Dec 2024 05:27:22 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 ## Summary by CodeRabbit - **New Features** - Introduced new methods for retrieving and counting `NewAction` entities based on application ID and IDs collection. - **Bug Fixes** - Removed outdated methods from the `NewActionRepositoryCE` interface to streamline functionality. - **Refactor** - Enhanced repository capabilities for managing `NewAction` entities while maintaining backward compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
68264f1e2e
commit
d9b1729ce3
|
|
@ -80,4 +80,14 @@ public interface CustomNewActionRepositoryCE extends AppsmithRepository<NewActio
|
|||
String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs);
|
||||
|
||||
Flux<NewAction> findAllByApplicationIds(List<String> branchedArtifactIds, List<String> includedFields);
|
||||
|
||||
// @Meta(cursorBatchSize = 10000)
|
||||
// TODO Implement cursor with batch size
|
||||
Flux<NewAction> findByApplicationId(String applicationId);
|
||||
|
||||
// @Meta(cursorBatchSize = 10000)
|
||||
// TODO Implement cursor with batch size
|
||||
Flux<NewAction> findAllByIdIn(Iterable<String> ids);
|
||||
|
||||
Mono<Long> countByDeletedAtNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.time.Instant;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
|
||||
import static org.springframework.data.mongodb.core.aggregation.Aggregation.match;
|
||||
|
|
@ -488,4 +489,24 @@ public class CustomNewActionRepositoryCEImpl extends BaseAppsmithRepositoryImpl<
|
|||
.fields(includedFields)
|
||||
.all();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<NewAction> findByApplicationId(String applicationId) {
|
||||
return queryBuilder()
|
||||
.criteria(Bridge.equal(NewAction.Fields.applicationId, applicationId))
|
||||
.all();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<NewAction> findAllByIdIn(Iterable<String> ids) {
|
||||
List<String> idList = StreamSupport.stream(ids.spliterator(), false).toList();
|
||||
return queryBuilder().criteria(Bridge.in(NewAction.Fields.id, idList)).all();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByDeletedAtNull() {
|
||||
return queryBuilder()
|
||||
.criteria(Bridge.exists(NewAction.Fields.deletedAt))
|
||||
.count();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,22 +5,12 @@ import com.appsmith.server.newactions.projections.IdAndDatasourceIdNewActionView
|
|||
import com.appsmith.server.projections.IdPoliciesOnly;
|
||||
import com.appsmith.server.repositories.BaseRepository;
|
||||
import com.appsmith.server.repositories.CustomNewActionRepository;
|
||||
import org.springframework.data.mongodb.repository.Meta;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NewActionRepositoryCE extends BaseRepository<NewAction, String>, CustomNewActionRepository {
|
||||
|
||||
@Meta(cursorBatchSize = 10000)
|
||||
Flux<NewAction> findByApplicationId(String applicationId);
|
||||
|
||||
@Meta(cursorBatchSize = 10000)
|
||||
Flux<NewAction> findAllByIdIn(Iterable<String> ids);
|
||||
|
||||
Mono<Long> countByDeletedAtNull();
|
||||
|
||||
Flux<IdPoliciesOnly> findIdsAndPolicyMapByApplicationIdIn(List<String> applicationIds);
|
||||
|
||||
Flux<IdAndDatasourceIdNewActionView> findIdAndDatasourceIdByApplicationIdIn(List<String> applicationIds);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user