Skip to content

chore: fixing file lock issues on autocommit#33549

Merged
sondermanish merged 6 commits intoreleasefrom
fix/autocommit
May 17, 2024
Merged

chore: fixing file lock issues on autocommit#33549
sondermanish merged 6 commits intoreleasefrom
fix/autocommit

Conversation

@sondermanish
Copy link
Contributor

@sondermanish sondermanish commented May 17, 2024

Description

  • Refactoring consolidated Api to replace autocommit trigger.
  • Reduced # db-calls for new pages.

Fixes #33384

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Added methods for retrieving and constructing application pages based on branch and mode.
    • Improved logic and error handling for fetching application pages.
    • Enhanced schema migration for Git-connected apps.
  • Refactor

    • Replaced method calls in ConsolidatedAPIServiceImpl for better performance.
    • Modified method in ApplicationServiceCE for finding applications by default ID, branch name, and mode.
  • Tests

    • Updated test cases in ConsolidatedAPIServiceImplTest for method call modifications.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9126493633
Commit: 82285f6
Cypress dashboard url: Click here!

@github-actions github-actions bot added Git Auto-commit Issues related to autocommit Git Platform Issues related to the git & the app platform Task A simple Todo labels May 17, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 17, 2024

Walkthrough

The changes encompass the addition of new methods and modifications to existing ones in various service classes to enhance application and page management based on different modes (view/edit). The primary objective is to eliminate redundant DSL migration calls in the ConsolidatedAPIServiceImpl to resolve file lock issues.

Changes

Files/Directories Change Summary
ApplicationServiceCE.java, ApplicationServiceCEImpl.java Added method findByDefaultIdBranchNameAndApplicationMode; refactored findBranchedApplicationId lambda expression.
NewPageServiceCE.java, NewPageServiceCEImpl.java Introduced methods for creating application pages DTO and revised page retrieval logic.
ApplicationPageServiceTest.java Added imports for ApplicationMode and Set, adjusted test methods for page retrieval based on application modes.

Assessment against linked issues

Objective Addressed Explanation
Remove redundant call to migrate DSL from the consolidated API (Issue #33384)

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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label May 17, 2024
sondermanish and others added 2 commits May 17, 2024 15:31
## Description
-`application` attribute of `pages` field in consolidated apis was
missing `isPublic` field.
it is part of transient properties which is not stored. Since the method
was not included in the application find flow the property was not
getting set.

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9125066518>
> Commit: 6c5bd4a
> Cypress dashboard: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9125066518&attempt=4&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank"> Click here!</a>
> The following are new failures, please fix them before merging the PR:
<ol>
> <li>cypress/e2e/Regression/ClientSide/Branding/Branding_spec.js
> <li>cypress/e2e/Regression/ClientSide/Fork/ForkApplication_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/OtherUIFeatures/ExportApplication_spec.js
>
<li>cypress/e2e/Regression/ClientSide/ProductRamps/PrivateEmbedRamp_spec.ts
> <li>cypress/e2e/Regression/ClientSide/Workspace/ShareAppTests_Spec.ts
</ol>
> To know the list of identified flaky tests - <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">Refer here</a>

<!-- end of auto-generated comment: Cypress test results  -->








## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
@sondermanish sondermanish requested a review from nidhi-nair May 17, 2024 10:04
@sondermanish sondermanish added the ok-to-test Required label for CI label May 17, 2024
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: 5

Out of diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java (1)

Line range hint 381-405: Enhance DSL migration logic to include default resource updates.

// The method `getPageDTOAfterMigratingDSL` has been modified to include logic for on-demand DSL migration based on the view mode.
// This change is part of the enhancements to improve the handling of DSL migrations and ensure that the migrated DSL is saved correctly.
// It is important to ensure that the default resources are updated correctly after the migration to maintain consistency across the application.

Comment on lines +285 to +318
public Mono<List<NewPage>> getPagesBasedOnApplicationMode(
Application branchedApplication, ApplicationMode applicationMode) {

Boolean viewMode = ApplicationMode.PUBLISHED.equals(applicationMode) ? Boolean.TRUE : Boolean.FALSE;

List<ApplicationPage> applicationPages = Boolean.TRUE.equals(viewMode)
? branchedApplication.getPublishedPages()
: branchedApplication.getPages();

Set<String> pageIds =
applicationPages.stream().map(ApplicationPage::getId).collect(Collectors.toSet());

return newPageService
.findByBranchNameAndDefaultPageId(branchName, defaultPageId, pagePermission.getReadPermission())
.flatMap(newPage -> {
return sendPageViewAnalyticsEvent(newPage, viewMode)
.then(getPage(newPage, viewMode))
.zipWith(Mono.just(newPage));
.findNewPagesByApplicationId(branchedApplication.getId(), pagePermission.getReadPermission())
.filter(newPage -> pageIds.contains(newPage.getId()))
.collectList()
.flatMap(newPageList -> {
if (Boolean.TRUE.equals(viewMode)) {
return Mono.just(newPageList);
}

// autocommit if migration is required
return migrateSchemasForGitConnectedApps(branchedApplication, newPageList)
.onErrorResume(error -> {
log.debug(
"Skipping the autocommit for applicationId : {} due to error; {}",
branchedApplication.getId(),
error.getMessage());

return Mono.just(Boolean.FALSE);
})
.thenReturn(newPageList);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor the method to handle autocommit during schema migration.

// The method `getPagesBasedOnApplicationMode` has been refactored to handle autocommit during schema migration.
// This is a critical change as it involves modifying the behavior of how pages are fetched based on the application mode.
// The method now includes logic to migrate schemas for Git-connected apps and handle errors during the migration process.
// This change is intended to fix file lock issues by removing redundant DSL migration calls.

@sondermanish sondermanish merged commit 2cb5390 into release May 17, 2024
@sondermanish sondermanish deleted the fix/autocommit branch May 17, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Git Auto-commit Issues related to autocommit Git Platform Issues related to the git & the app platform ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: remove redundant call to migrate dsl from the consolidated Api, it's causing file lock issues.

2 participants