From 681f2bcd3420e3034ef222d41d276f5a373d7adc Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Fri, 30 Aug 2024 16:09:45 +0800 Subject: [PATCH] refactor: remove unused code --- hrp/pkg/uixt/ext.go | 12 ------------ hrp/pkg/uixt/popups.go | 9 --------- hrp/pkg/uixt/service_vedem.go | 14 ++++---------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index 4bb0072f..ad2bc232 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -60,18 +60,6 @@ type ScreenResult struct { Icons UIResultMap `json:"icons"` // CV 识别的图标 Tags []string `json:"tags"` // tags for image, e.g. ["feed", "ad", "live"] Popup *PopupInfo `json:"popup,omitempty"` - - SwipeStartTime int64 `json:"swipe_start_time"` // 滑动开始时间戳 - SwipeFinishTime int64 `json:"swipe_finish_time"` // 滑动结束时间戳 - FetchVideoStartTime int64 `json:"fetch_video_start_time"` // 抓取视频开始时间戳 - FetchVideoFinishTime int64 `json:"fetch_video_finish_time"` // 抓取视频结束时间戳 - - FetchVideoElapsed int64 `json:"fetch_video_elapsed"` // 抓取视频耗时(ms) - ScreenshotTakeElapsed int64 `json:"screenshot_take_elapsed"` // 设备截图耗时(ms) - ScreenshotCVElapsed int64 `json:"screenshot_cv_elapsed"` // CV 识别耗时(ms) - - // 当前 Feed/Live 整体耗时 - TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms) } type ScreenResultMap map[string]*ScreenResult // key is date time diff --git a/hrp/pkg/uixt/popups.go b/hrp/pkg/uixt/popups.go index 43b1717e..9c4328c1 100644 --- a/hrp/pkg/uixt/popups.go +++ b/hrp/pkg/uixt/popups.go @@ -71,12 +71,6 @@ func (dExt *DriverExt) AutoPopupHandler() error { return dExt.handleTextPopup(screenResult.Texts) } -const ( - CloseStatusFound = "found" - CloseStatusSuccess = "success" - CloseStatusFail = "fail" -) - // ClosePopupsResult represents the result of recognized popup to close type ClosePopupsResult struct { Type string `json:"type"` @@ -87,9 +81,7 @@ type ClosePopupsResult struct { type PopupInfo struct { *ClosePopupsResult - CloseStatus string `json:"close_status"` // found/success/fail ClosePoints []PointF `json:"close_points,omitempty"` // CV 识别的所有关闭按钮(仅关闭按钮,可能存在多个) - RetryCount int `json:"retry_count"` PicName string `json:"pic_name"` PicURL string `json:"pic_url"` } @@ -129,7 +121,6 @@ func (dExt *DriverExt) ClosePopupsHandler() (err error) { return nil } - popup.CloseStatus = CloseStatusFound log.Info(). Interface("closePoint", closePoint). Interface("popup", popup). diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index 2e263762..e7ffec81 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -386,7 +386,6 @@ type IImageService interface { // GetScreenResult takes a screenshot, returns the image recognization result func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) { - startTime := time.Now() fileName := builtin.GenNameWithTimestamp("%d_screenshot") actionOptions := NewActionOptions(options...) screenshotActions := actionOptions.screenshotActions() @@ -397,14 +396,12 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S if err != nil { return } - screenshotTakeElapsed := time.Since(startTime).Milliseconds() screenResult = &ScreenResult{ - bufSource: bufSource, - imagePath: imagePath, - Tags: nil, - Resolution: dExt.WindowSize, - ScreenshotTakeElapsed: screenshotTakeElapsed, + bufSource: bufSource, + imagePath: imagePath, + Tags: nil, + Resolution: dExt.WindowSize, } imageResult, err := dExt.ImageService.GetImage(bufSource, options...) @@ -414,7 +411,6 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S } if imageResult != nil { screenResult.ImageResult = imageResult - screenResult.ScreenshotCVElapsed = time.Since(startTime).Milliseconds() - screenshotTakeElapsed screenResult.Texts = imageResult.OCRResult.ToOCRTexts() screenResult.UploadedURL = imageResult.URL screenResult.Icons = imageResult.UIResult @@ -438,8 +434,6 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S log.Debug(). Str("imagePath", imagePath). Str("imageUrl", screenResult.UploadedURL). - Int64("screenshot_take_elapsed(ms)", screenResult.ScreenshotTakeElapsed). - Int64("screenshot_cv_elapsed(ms)", screenResult.ScreenshotCVElapsed). Msg("log screenshot") return screenResult, nil }