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

优化biz信息显示 #897

Merged
merged 4 commits into from
Apr 1, 2024
Merged

优化biz信息显示 #897

merged 4 commits into from
Apr 1, 2024

Conversation

gaosaroma
Copy link
Collaborator

@gaosaroma gaosaroma commented Apr 1, 2024

Summary by CodeRabbit

  • Refactor
    • Updated the output format of the toString() method in BizModel to improve the representation of state history by changing terminology.
    • Modified the toString method in BizStateRecord to enhance clarity by changing the order of state and date.

# Conflicts:
#	sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/model/BizModel.java
Copy link
Contributor

coderabbitai bot commented Apr 1, 2024

Walkthrough

The recent updates focus on enhancing the representation of state history within the BizModel and BizInfo classes. Specifically, the toString() method in BizModel now uses bizStateChangeLogs for a clearer depiction of state changes. Meanwhile, in BizInfo, the toString method of the BizStateRecord class has been adjusted to present the state and date in a new order, improving readability and consistency in logging.

Changes

Files Change Summary
.../container/model/BizModel.java
.../spi/model/BizInfo.java
Updated toString() method:
- BizModel: Replaced bizStateRecords with bizStateChangeLogs.
- BizInfo: Modified toString in BizStateRecord to change the order of state and date.

🐇✨
In the realm of code, where changes abound,
A rabbit hopped in, leaving footprints on the ground.
"From records to logs," it cheerfully said,
"And states before dates, let confusion shed!"
With a twitch of its nose and a flick of its ear,
The rabbit then vanished, leaving improvements clear.
🌟🐾

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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 38405da and 8398ec9.
Files selected for processing (2)
  • sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/model/BizModel.java (1 hunks)
  • sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/model/BizInfo.java (1 hunks)
Additional Context Used

@@ -147,7 +147,7 @@ public BizStateRecord(Date changeTime, BizState state) {
@Override
public String toString() {
String date = sdf.format(changeTime);
return String.format("state change to %s at %s", state, date);
return String.format("state at %s to %s", date, state);
Copy link
Contributor

Choose a reason for hiding this comment

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

The change in the order of state and date in the toString method of the BizStateRecord class aligns with the PR's objective to enhance readability. However, it would be beneficial to add a comment explaining the rationale behind this change for future maintainers.

+            // Reordered to improve readability by showing the date before the state
             return String.format("state at %s to %s", date, state);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return String.format("state at %s to %s", date, state);
// Reordered to improve readability by showing the date before the state
return String.format("state at %s to %s", date, state);

Comment on lines 411 to 412
return "Ark Biz: " + getIdentity() + ",\n classloader: " + classLoader
+ ",\n current state: " + bizState + ",\n history states: " + bizStateChangeLogs;
Copy link
Contributor

Choose a reason for hiding this comment

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

The toString method references bizStateChangeLogs, which is not defined within the provided code snippet. Ensure that bizStateChangeLogs is properly defined and initialized to avoid potential null reference issues and to accurately represent the state history.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8398ec9 and 72dfc44.
Files selected for processing (1)
  • sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/model/BizModel.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/model/BizModel.java
Additional Context Used

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.86%. Comparing base (38405da) to head (1b45ca8).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #897      +/-   ##
============================================
+ Coverage     78.72%   78.86%   +0.14%     
  Complexity      837      837              
============================================
  Files           164      164              
  Lines          6796     6796              
  Branches       1009     1009              
============================================
+ Hits           5350     5360      +10     
+ Misses          923      912      -11     
- Partials        523      524       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -147,7 +147,7 @@ public BizStateRecord(Date changeTime, BizState state) {
@Override
public String toString() {
String date = sdf.format(changeTime);
return String.format("state change to %s at %s", state, date);
return String.format("state at %s to %s", date, state);
Copy link
Collaborator

Choose a reason for hiding this comment

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

不是换成时间:state 吗?
String.format("%s -> %s", date, state);

@sofastack-cla sofastack-cla bot added size/S and removed size/XS labels Apr 1, 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: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 72dfc44 and 1b45ca8.
Files selected for processing (2)
  • sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/model/BizModelTest.java (1 hunks)
  • sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/model/BizInfo.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/model/BizInfo.java
Additional Context Used
Additional comments not posted (4)
sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/model/BizModelTest.java (4)

67-67: The assertion checks for the presence of "-> resolved" in the toString output, aligning with the PR's objective to enhance the presentation of state transitions. Ensure that the toString method in BizModel is indeed updated to reflect this new format.


72-73: These assertions verify the state transition from "resolved" to "activated". It's good practice to ensure that the toString method's output is consistent and accurately reflects the state transitions.


78-80: Assertions here check for a sequence of state transitions up to "deactivated". This consistency in testing the toString output for each state transition is crucial for validating the PR's enhancements.


84-87: The final set of assertions covers the entire sequence of state transitions, including the transition to "unresolved". This thorough testing ensures that the toString method's enhancements are correctly implemented across all state changes.

Copy link
Collaborator

@lvjing2 lvjing2 left a comment

Choose a reason for hiding this comment

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

LGTM

@lvjing2 lvjing2 merged commit 1bf4217 into sofastack:master Apr 1, 2024
7 checks passed
lvjing2 pushed a commit that referenced this pull request Apr 1, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

(cherry picked from commit 1bf4217)
lvjing2 pushed a commit that referenced this pull request Apr 1, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

(cherry picked from commit 1bf4217)
lvjing2 added a commit that referenced this pull request Apr 1, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

(cherry picked from commit 1bf4217)

Co-authored-by: Lipeng <44571204+gaosaroma@users.noreply.github.com>
lvjing2 added a commit that referenced this pull request Apr 1, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

(cherry picked from commit 1bf4217)

Co-authored-by: Lipeng <44571204+gaosaroma@users.noreply.github.com>
lvjing2 added a commit that referenced this pull request Apr 7, 2024
* 优化biz信息显示 (#897)

* 优化显示

* fix as bizStateRecords

* 更新显示

(cherry picked from commit 1bf4217)

* update version to 3.0.4

---------

Co-authored-by: Lipeng <44571204+gaosaroma@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants