perf(platform): reuse batch path for vehicle overview

This commit is contained in:
lingniu
2026-07-04 03:15:31 +08:00
parent e35565f993
commit 5d49675582
2 changed files with 35 additions and 0 deletions

View File

@@ -99,6 +99,20 @@ func (s *Service) VehicleRealtime(ctx context.Context, query url.Values) (Page[V
func (s *Service) VehicleServiceOverview(ctx context.Context, keyword string, protocol string) (VehicleServiceOverview, error) {
keyword = strings.TrimSpace(keyword)
protocol = strings.TrimSpace(protocol)
if batchStore, ok := s.store.(VehicleOverviewBatchStore); ok {
page, err := batchStore.VehicleServiceOverviews(ctx, VehicleOverviewBatchQuery{
Keywords: []string{keyword},
Protocol: protocol,
Limit: 1,
})
if err != nil {
return VehicleServiceOverview{}, err
}
if len(page.Items) > 0 {
return page.Items[0], nil
}
return *buildVehicleServiceOverview("", keyword, &VehicleIdentityResolution{LookupKey: keyword, Protocols: []string{}}, nil, nil, nil, Page[HistoryLocationRow]{}, Page[RawFrameRow]{}, Page[DailyMileageRow]{}, Page[QualityIssueRow]{}), nil
}
vehicleQuery := url.Values{"keyword": {keyword}, "limit": {"20"}}
if protocol != "" {
vehicleQuery.Set("protocol", protocol)