Skip to content

fix: Processing for document export sheet with more than 32 characters #2740

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

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

shaohuzhang1
Copy link
Contributor

fix: Processing for document export sheet with more than 32 characters

Copy link

f2c-ci-robot bot commented Mar 31, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Mar 31, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shaohuzhang1 shaohuzhang1 merged commit 7a99c78 into main Mar 31, 2025
3 of 4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_export branch March 31, 2025 03:17
@@ -703,6 +703,8 @@ def merge_problem(paragraph_list: List[Dict], problem_mapping_list: List[Dict],

@staticmethod
def reset_document_name(document_name):
if document_name is not None:
document_name = document_name.strip()[0:29]
if document_name is None or not Utils.valid_sheet_name(document_name):
return "Sheet"
return document_name.strip()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function reset_document_name has a few improvements that can be made to enhance its readability and potentially reduce redundancy:

  1. Stripping Whitespace: The line document_name.strip() is redundant inside the condition if document_name is not None, as it would have been stripped anyway before entering the conditional.

  2. Truncating Document Name: While trimming the string to 29 characters might be useful for formatting in some contexts, it should be done based on user preferences rather than automatically changing lengths throughout the application's execution.

Here's an optimized version of the code:

class MergeProblemHelper:
    @staticmethod
    def reset_document_name(document_name):
        """Resets the document name with specific rules."""
        # Strip leading and trailing whitespace
        document_name = document_name.strip()
        
        # Check if document name is valid
        if document_name is None or not Utils.valid_sheet_name(document_name):
            return "Sheet"
        
        # Truncate document name (optional), e.g., for filename purposes
        document_name = document_name[:29].strip()
        
        return document_name
    
    # ... other static methods ...

This refactoring makes each step clear and removes unnecessary logic, maintaining the original functionality while being more efficient and easier to understand.

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.

1 participant