Skip to content

fix: Fix page history version bug#235

Merged
hexqi merged 13 commits intodevelopfrom
release/v1.0.1-alpha.1
May 28, 2025
Merged

fix: Fix page history version bug#235
hexqi merged 13 commits intodevelopfrom
release/v1.0.1-alpha.1

Conversation

@lu-yg
Copy link
Collaborator

@lu-yg lu-yg commented May 28, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added the ability to retrieve the maximum version number of a page's history.
  • Bug Fixes

    • Page history queries now return results sorted by last updated time.
    • Page version assignment during creation and updates is now more accurate.
  • Style

    • Improved code formatting and consistency across various files for better readability.
  • Tests

    • Minor formatting improvements in test files.

@coderabbitai
Copy link

coderabbitai bot commented May 28, 2025

Walkthrough

This update primarily consists of whitespace, formatting, and import cleanup across several Java source and test files. Additionally, new functionality is introduced for handling page history versions: a method to retrieve the maximum version of a page's history is added, and related logic is updated to utilize this method. The SQL mapping for querying page history is also updated to ensure results are ordered by the last updated time.

Changes

Files/Groups Change Summary
ExceptionEnum.java, SecurityFileCheckUtil.java, Utils.java, AiChatConfig.java, ...Controller.java Whitespace, indentation, or formatting adjustments; no logic or control flow changes.
.../User.java, .../AiChatClientTest.java, .../ComponentServiceImpl.java, .../DataSourceController.java Removal of unused import statements.
I18nEntryController.java Removed extra space in method signature of getI18nEntriesByApp.
PageHistoryService.java Added selectMaxVersionOfPageHistory(String name, Integer app) method to the interface.
PageHistoryServiceImpl.java Added DEFAULT_PAGE_HISTORY_VERSION constant and implemented selectMaxVersionOfPageHistory method.
PageServiceImpl.java Updated logic to set version using new method; formatting fix in checkDelete.
PageHistoryMapper.xml Added ORDER BY last_updated_time ASC to queryPageHistoryByName select statement.

Sequence Diagram(s)

sequenceDiagram
    participant Service as PageServiceImpl
    participant HistoryService as PageHistoryServiceImpl
    participant Mapper as PageHistoryMapper

    Service->>HistoryService: selectMaxVersionOfPageHistory(name, app)
    HistoryService->>Mapper: queryPageHistoryByName(name, app)
    Mapper-->>HistoryService: List<PageHistory> (ordered by last_updated_time ASC)
    alt List is empty or null
        HistoryService-->>Service: "0"
    else
        HistoryService-->>Service: last PageHistory.version
    end
Loading

Poem

In the garden where code lines grow,
Whitespace pruned, imports let go.
A versioning hop for page history’s sake,
Now “0” or the max, no more “draft” to make.
With queries sorted and methods anew,
This bunny’s proud of what devs can do!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6be7d and a8d5739.

📒 Files selected for processing (1)
  • base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@github-actions
Copy link

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copy link

@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: 3

🧹 Nitpick comments (1)
base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java (1)

28-30: Remove unused import.

The Collection import on line 30 appears to be unused in this implementation.

  import org.springframework.util.CollectionUtils;

- import java.util.Collection;
  import java.util.List;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07dab03 and 1f6be7d.

📒 Files selected for processing (19)
  • base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/common/utils/Utils.java (2 hunks)
  • base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/controller/CanvasController.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/controller/DataSourceController.java (0 hunks)
  • base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java (2 hunks)
  • base/src/main/java/com/tinyengine/it/model/entity/User.java (0 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/PageHistoryService.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java (3 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java (3 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java (3 hunks)
  • base/src/main/resources/mappers/PageHistoryMapper.xml (1 hunks)
  • base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java (1 hunks)
  • base/src/test/java/com/tinyengine/it/controller/BlockGroupControllerTest.java (1 hunks)
  • base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java (0 hunks)
💤 Files with no reviewable changes (3)
  • base/src/main/java/com/tinyengine/it/controller/DataSourceController.java
  • base/src/main/java/com/tinyengine/it/model/entity/User.java
  • base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java
🔇 Additional comments (20)
base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java (1)

83-83: Consistent formatting adjustment
The extra space before the first parameter in the getI18nEntriesByApp method signature has been removed, aligning with the project's standard formatting. This change is purely stylistic and does not affect functionality.

base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java (1)

208-208: Approve formatting adjustment in testUpdateBlocks.

The indentation change in the verify call is purely stylistic and aligns with surrounding code conventions. No functional impact.

base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java (1)

50-50: Stylistic alignment: consistent if formatting

Adding a space after the if keyword (if (user == null)) improves readability and aligns with the project's established code style. No functional behavior is affected.

base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java (3)

223-223: Formatting improvement approved

The added space after commas in the call to buildComponentList improves readability without altering functionality.


295-295: Spacing refinement approved

The insertion of spaces around the logical && operators in the if condition enhances consistency and readability. No behavior changes.


357-358: Method signature formatting approved

The adjustment of spaces in the buildComponentList method signature parameters aligns with project style guidelines.

base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java (1)

248-248: LGTM - Good formatting improvement.

The addition of spaces after commas in the enum constructor calls improves code readability and follows standard Java formatting conventions.

Also applies to: 253-253

base/src/main/java/com/tinyengine/it/controller/CanvasController.java (1)

58-66: LGTM - Improved annotation formatting.

The indentation improvements for the Swagger/OpenAPI annotations enhance code readability and maintain consistent formatting across the controller methods.

base/src/main/java/com/tinyengine/it/common/utils/Utils.java (1)

403-403: LGTM - Good spacing improvement.

Adding blank lines after methods improves code readability and maintains consistent visual separation between different method definitions.

Also applies to: 416-416

base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java (2)

45-46: LGTM - Trailing space cleanup.

Removing the trailing space improves code quality and maintains clean formatting standards.


45-46: Clarify PR scope - potential missing functional changes.

While the formatting improvements are good, there's a discrepancy between the PR objectives and visible changes. The PR is titled "fix: Fix page history version bug" and the AI summary mentions new functionality for handling page history versions (like selectMaxVersionOfPageHistory method and SQL mapping updates), but only formatting changes are visible in the provided files.

Please verify if the functional bug fix changes are missing from the review or if this PR only contains formatting improvements.

Likely an incorrect or invalid review comment.

base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (1)

73-73: LGTM: Formatting improvement

The indentation alignment of the string concatenation improves code readability while maintaining the same functionality.

base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java (1)

122-122: LGTM: Annotation formatting improvement

The indentation adjustment of the @ApiResponse annotation improves consistency with the surrounding Swagger documentation formatting.

base/src/test/java/com/tinyengine/it/controller/BlockGroupControllerTest.java (1)

61-61: LGTM: Test formatting improvement

The indentation adjustment of the method arguments improves code readability while preserving the exact same test functionality.

base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java (2)

114-114: LGTM: Swagger annotation formatting improvements

The indentation adjustments of the @ApiResponse annotations improve consistency in the API documentation formatting.

Also applies to: 185-186


1-196: Inconsistency between PR objectives and visible changes

The PR is titled "fix: Fix page history version bug" and the AI summary mentions functional changes like adding a method to retrieve maximum page history version and SQL query updates. However, the changes shown in this file are purely formatting adjustments to Swagger annotations. The actual bug fix implementation is not visible in the provided code.

Let me verify if the actual functional changes exist elsewhere in the codebase:

#!/bin/bash
# Description: Search for page history version-related functional changes
# Expected: Find the actual bug fix implementation mentioned in PR objectives

# Search for new methods related to max version of page history
rg -A 10 "selectMaxVersionOfPageHistory|maxVersion" --type java

# Search for recent changes in PageHistoryService and related files
fd "PageHistory" --type f --extension java | head -10

# Look for SQL mapping changes mentioned in summary
fd "PageHistoryMapper" --type f --extension xml

Likely an incorrect or invalid review comment.

base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java (2)

287-287: LGTM: Initial version set to "0" for new pages.

This change from the hardcoded "draft" string to "0" establishes a proper numeric baseline for version tracking.


545-545: LGTM: Consistent code formatting.

Good formatting improvement adding space after if keyword.

base/src/main/java/com/tinyengine/it/service/app/PageHistoryService.java (1)

94-101: LGTM: Well-defined service method addition.

The new method signature is clear and properly documented. The method name selectMaxVersionOfPageHistory accurately describes its purpose.

base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java (1)

41-41: LGTM: Good constant definition.

The DEFAULT_PAGE_HISTORY_VERSION constant provides a clear default value and improves maintainability.

@github-actions
Copy link

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@hexqi hexqi merged commit 6e18d53 into develop May 28, 2025
1 check passed
lu-yg added a commit to lu-yg/tiny-engine-backend-java that referenced this pull request Oct 23, 2025
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