-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
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)) |
There was a problem hiding this comment.
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:
-
Error Handling:
- Both methods now return an additional error parameter to allow for better error management.
-
Conversion Loop:
- In both implementations, there's a loop that copies model record values to DTO objects (
dto.BackupRecords
) using thecopier
library. This conversion is wrapped in an error-checking block.
- In both implementations, there's a loop that copies model record values to DTO objects (
-
Pagination and Sorting:
- Pagination logic remains mostly unchanged (e.g., using
page
andpageSize
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.).
- Pagination logic remains mostly unchanged (e.g., using
-
Helper Structs and WaitGroups:
- The use of
HelperStructs
andWaitGroups
hasn't changed but their purpose and implementation remain consistent with previous functions.
- The use of
-
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 |
There was a problem hiding this comment.
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:
- Comments Consistency: Ensure all
@Description
,@Summary
headers have consistent formatting. - Variable Naming: The function parameters should use meaningful names to improve readability.
Specific Changes
BaseApi.go
-
Updated
LoadBackupSize
andLoadBackupSizeByCronjob
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
- 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; |
There was a problem hiding this comment.
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:
-
Code Duplication: Some duplication was removed from the
search
function to avoid redundancy. -
Loading Indicator: A loading indicator is shown during search operations to improve user experience by indicating ongoing processing without displaying an empty table prematurely.
-
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.
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[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 |
No description provided.