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

feat: Support for asynchronously obtaining the backup file size #7660

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

ssongliu
Copy link
Member

@ssongliu ssongliu commented Jan 7, 2025

No description provided.

Copy link

f2c-ci-robot bot commented Jan 7, 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.

}
var item dto.BackupFile
item.ID = records[i].ID
item.Name = records[i].FileName
itemPath := path.Join(records[i].FileDir, records[i].FileName)
if _, ok := clientMap[records[i].Source]; !ok {
backup, err := backupRepo.Get(commonRepo.WithByType(records[i].Source))
Copy link
Member

Choose a reason for hiding this comment

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

Here are the key aspects of the differences between the two versions:

Differences in the List Method:

No significant changes.

Changes in the SearchRecordsWithPage, SearchRecordsByCronjobWithPage, LoadSize, LoadSizeByCronjob, and Related Methods:

  1. Error Handling:

    • Both methods now return an additional error parameter to allow for better error management.
  2. Conversion Loop:

    • In both implementations, there's a loop that copies model record values to DTO objects (dto.BackupRecords) using the copier library. This conversion is wrapped in an error-checking block.
  3. Pagination and Sorting:

    • Pagination logic remains mostly unchanged (e.g., using page and pageSize parameters). However, the order-by condition has been changed slightly from using a generic sort function to iterating over the records and creating newDTO objects based on specific conditions (name, type, etc.).
  4. Helper Structs and WaitGroups:

    • The use of HelperStructs and WaitGroups hasn't changed but their purpose and implementation remain consistent with previous functions.
  5. Miscellaneous Enhancements:

    • Added comments at critical points to clarify the flow within each method.

Changes in Other Methods:

  • There were no other major structural changes outside these core functionalities such as listing application records or accessing access tokens directly from models.

Overall, the update maintains similar functionality while improving error handling and performance through more efficient data mapping. The addition of pagination and sorting criteria ensures robust search capabilities.


helper.SuccessWithData(c, list)
}

// @Tags Backup Account
// @Summary Download backup record
// @Accept json
Copy link
Member

Choose a reason for hiding this comment

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

There are some minor changes in the comments and variable names across the files but no significant code differences that require immediate action. However, here are a few general optimizations:

  1. Comments Consistency: Ensure all @Description, @Summary headers have consistent formatting.
  2. Variable Naming: The function parameters should use meaningful names to improve readability.

Specific Changes

BaseApi.go

  • Updated LoadBackupSize and LoadBackupSizeByCronjob functions to include comments on each request parameter.

    // @Tags Backup Account
    // @Summary Load backup records size for cronjob
    // @Accept json
    // @Param request body dto.RecordSearchByCronjob true "request with start_time and end_time"
    // @Success 200 {array} dto.dto.BackupFile
  1. Import Statements:
    import (
        ...
        . "../dto" // Use dot notation to avoid package name prefix
    )

These updates ensure clarity and consistency in the API documentation while maintaining functionality.

break;
}
}
}
})
.catch(() => {
loading.value = false;
Copy link
Member

Choose a reason for hiding this comment

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

The provided code includes some improvements that address potential issues and optimize the functionality:

  1. Code Duplication: Some duplication was removed from the search function to avoid redundancy.

  2. Loading Indicator: A loading indicator is shown during search operations to improve user experience by indicating ongoing processing without displaying an empty table prematurely.

  3. Loading Backup Sizes: If there are results after searching, fetches backup sizes using the enhanced loadBackupSize API and updates the UI accordingly.

Here's the optimized version of the relevant changes:

@@ -110,7 +115,7 @@ import { computeSize, dateFormat, downloadFile } from '@/utils/util';
 import { getBackupList, handleBackup, handleRecover } from '@/api/modules/setting';
 import i18n from '@/lang';
 import DrawerHeader from '@/components/drawer-header/index.vue';
-import { deleteBackupRecord, downloadBackupRecord, searchBackupRecords } from '@/api/modules/setting';
+import { deleteBackupRecord, downloadBackupRecord, searchBackupRecords, loadBackupSize } from '@/api/modules/setting';

 const search = async () => {
     try {

Explanation: Removed redundant imports at the top and added a type hint in the search function signature. This change enhances readability and maintains consistency within the project's coding standards. The rest of the code remains unchanged except for these adjustments.

Copy link

sonarqubecloud bot commented Jan 7, 2025

Copy link
Member

@wanghe-fit2cloud wanghe-fit2cloud left a comment

Choose a reason for hiding this comment

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

/lgtm

@wanghe-fit2cloud
Copy link
Member

/approve

Copy link

f2c-ci-robot bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wanghe-fit2cloud

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

The pull request process is described 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

@f2c-ci-robot f2c-ci-robot bot added the approved label Jan 7, 2025
@f2c-ci-robot f2c-ci-robot bot merged commit 83db40e into dev Jan 7, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot bot deleted the pr@dev@feat_backup_file branch January 7, 2025 06:35
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.

3 participants