diff --git a/backend/internal/service/gateway_multiplatform_test.go b/backend/internal/service/gateway_multiplatform_test.go index 6568b3f6b4..badb2427cf 100644 --- a/backend/internal/service/gateway_multiplatform_test.go +++ b/backend/internal/service/gateway_multiplatform_test.go @@ -3361,8 +3361,8 @@ func TestGatewayService_GroupResolution_ReusesContextGroup(t *testing.T) { account, err := svc.SelectAccountForModelWithExclusions(ctx, &groupID, "", "claude-3-5-sonnet-20241022", nil) require.NoError(t, err) require.NotNil(t, account) - require.Equal(t, 1, groupRepo.getByIDCalls) // +1 for require_privacy_set check - require.Equal(t, 0, groupRepo.getByIDLiteCalls) + require.Equal(t, 0, groupRepo.getByIDCalls) + require.Equal(t, 1, groupRepo.getByIDLiteCalls) // require_privacy_set,不走账号计数聚合 } func TestGatewayService_GroupResolution_IgnoresInvalidContextGroup(t *testing.T) { @@ -3404,8 +3404,8 @@ func TestGatewayService_GroupResolution_IgnoresInvalidContextGroup(t *testing.T) account, err := svc.SelectAccountForModelWithExclusions(ctx, &groupID, "", "claude-3-5-sonnet-20241022", nil) require.NoError(t, err) require.NotNil(t, account) - require.Equal(t, 1, groupRepo.getByIDCalls) // +1 for require_privacy_set check - require.Equal(t, 1, groupRepo.getByIDLiteCalls) + require.Equal(t, 0, groupRepo.getByIDCalls) + require.Equal(t, 2, groupRepo.getByIDLiteCalls) // 分组解析 + require_privacy_set } func TestGatewayService_GroupContext_OverwritesInvalidContextGroup(t *testing.T) { @@ -3474,8 +3474,8 @@ func TestGatewayService_GroupResolution_FallbackUsesLiteOnce(t *testing.T) { account, err := svc.SelectAccountForModelWithExclusions(ctx, &groupID, "", "claude-3-5-sonnet-20241022", nil) require.NoError(t, err) require.NotNil(t, account) - require.Equal(t, 1, groupRepo.getByIDCalls) // +1 for require_privacy_set check - require.Equal(t, 1, groupRepo.getByIDLiteCalls) + require.Equal(t, 0, groupRepo.getByIDCalls) + require.Equal(t, 2, groupRepo.getByIDLiteCalls) // fallback 解析 + require_privacy_set } func TestGatewayService_ResolveGatewayGroup_DetectsFallbackCycle(t *testing.T) { diff --git a/backend/internal/service/gateway_scheduling.go b/backend/internal/service/gateway_scheduling.go index f5dd160c79..059d7e2b2c 100644 --- a/backend/internal/service/gateway_scheduling.go +++ b/backend/internal/service/gateway_scheduling.go @@ -1893,10 +1893,10 @@ func (s *GatewayService) selectAccountForModelWithPlatform(ctx context.Context, preferOAuth := platform == PlatformGemini routingAccountIDs := s.routingAccountIDsForRequest(ctx, groupID, requestedModel, platform) - // require_privacy_set: 获取分组信息 + // require_privacy_set: 获取分组配置。GetByID 会聚合账号计数,旧选号路径不能用它。 var schedGroup *Group if groupID != nil && s.groupRepo != nil { - schedGroup, _ = s.groupRepo.GetByID(ctx, *groupID) + schedGroup, _ = s.groupRepo.GetByIDLite(ctx, *groupID) } var accounts []Account @@ -2159,10 +2159,10 @@ func (s *GatewayService) selectAccountWithMixedScheduling(ctx context.Context, g preferOAuth := nativePlatform == PlatformGemini routingAccountIDs := s.routingAccountIDsForRequest(ctx, groupID, requestedModel, nativePlatform) - // require_privacy_set: 获取分组信息 + // require_privacy_set: 获取分组配置。GetByID 会聚合账号计数,旧选号路径不能用它。 var schedGroup *Group if groupID != nil && s.groupRepo != nil { - schedGroup, _ = s.groupRepo.GetByID(ctx, *groupID) + schedGroup, _ = s.groupRepo.GetByIDLite(ctx, *groupID) } var accounts []Account diff --git a/backend/internal/service/openai_account_scheduler.go b/backend/internal/service/openai_account_scheduler.go index 28e30dfadf..3cf56f234e 100644 --- a/backend/internal/service/openai_account_scheduler.go +++ b/backend/internal/service/openai_account_scheduler.go @@ -1432,10 +1432,10 @@ func (s *defaultOpenAIAccountScheduler) selectByLoadBalance( accounts = modelFiltered } - // require_privacy_set: 获取分组信息 + // require_privacy_set: 获取分组配置。GetByID 会聚合账号计数,选号不能走它。 var schedGroup *Group if req.GroupID != nil && s.service.schedulerSnapshot != nil { - schedGroup, _ = s.service.schedulerSnapshot.GetGroupByID(ctx, *req.GroupID) + schedGroup, _ = s.service.schedulerSnapshot.GetGroupByIDLite(ctx, *req.GroupID) } filterStats := openAISelectionFilterStats{pool: len(accounts)} @@ -2214,7 +2214,8 @@ func (s *OpenAIGatewayService) loadOpenAIGroupRequiresPrivacySet(ctx context.Con if s == nil || groupID == nil || s.schedulerSnapshot == nil { return false } - group, err := s.schedulerSnapshot.GetGroupByID(ctx, *groupID) + // GetByID 会聚合账号计数;隐私开关只在分组行上。 + group, err := s.schedulerSnapshot.GetGroupByIDLite(ctx, *groupID) if err != nil { return true }