Skip to content

Commit c08889b

Browse files
committed
fix: remove unused preload/snapshot functions and fix gofmt
1 parent 57ebe38 commit c08889b

2 files changed

Lines changed: 13 additions & 113 deletions

File tree

backend/internal/handler/admin/admin_service_stub_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ import (
1010
)
1111

1212
type stubAdminService struct {
13-
users []service.User
14-
apiKeys []service.APIKey
15-
groups []service.Group
16-
accounts []service.Account
17-
proxies []service.Proxy
18-
proxyCounts []service.ProxyWithAccountCount
19-
redeems []service.RedeemCode
20-
createdAccounts []*service.CreateAccountInput
21-
createdProxies []*service.CreateProxyInput
22-
updatedProxyIDs []int64
23-
updatedProxies []*service.UpdateProxyInput
24-
testedProxyIDs []int64
13+
users []service.User
14+
apiKeys []service.APIKey
15+
groups []service.Group
16+
accounts []service.Account
17+
proxies []service.Proxy
18+
proxyCounts []service.ProxyWithAccountCount
19+
redeems []service.RedeemCode
20+
createdAccounts []*service.CreateAccountInput
21+
createdProxies []*service.CreateProxyInput
22+
updatedProxyIDs []int64
23+
updatedProxies []*service.UpdateProxyInput
24+
testedProxyIDs []int64
2525
createAccountErr error
2626
updateAccountErr error
2727
bulkUpdateAccountErr error
2828
checkMixedErr error
29-
lastMixedCheck struct {
29+
lastMixedCheck struct {
3030
accountID int64
3131
platform string
3232
groupIDs []int64

backend/internal/service/admin_service.go

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,41 +2288,6 @@ func (s *adminServiceImpl) checkMixedChannelRisk(ctx context.Context, currentAcc
22882288
return nil
22892289
}
22902290

2291-
func (s *adminServiceImpl) preloadMixedChannelRiskData(ctx context.Context, groupIDs []int64) (map[int64][]Account, map[int64]string, error) {
2292-
accountsByGroup := make(map[int64][]Account)
2293-
groupNameByID := make(map[int64]string)
2294-
if len(groupIDs) == 0 {
2295-
return accountsByGroup, groupNameByID, nil
2296-
}
2297-
2298-
seen := make(map[int64]struct{}, len(groupIDs))
2299-
for _, groupID := range groupIDs {
2300-
if groupID <= 0 {
2301-
continue
2302-
}
2303-
if _, ok := seen[groupID]; ok {
2304-
continue
2305-
}
2306-
seen[groupID] = struct{}{}
2307-
2308-
accounts, err := s.accountRepo.ListByGroup(ctx, groupID)
2309-
if err != nil {
2310-
return nil, nil, fmt.Errorf("get accounts in group %d: %w", groupID, err)
2311-
}
2312-
accountsByGroup[groupID] = accounts
2313-
2314-
group, err := s.groupRepo.GetByID(ctx, groupID)
2315-
if err != nil {
2316-
continue
2317-
}
2318-
if group != nil {
2319-
groupNameByID[groupID] = group.Name
2320-
}
2321-
}
2322-
2323-
return accountsByGroup, groupNameByID, nil
2324-
}
2325-
23262291
func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs []int64) error {
23272292
if len(groupIDs) == 0 {
23282293
return nil
@@ -2352,71 +2317,6 @@ func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs [
23522317
return nil
23532318
}
23542319

2355-
func (s *adminServiceImpl) checkMixedChannelRiskWithPreloaded(currentAccountID int64, currentAccountPlatform string, groupIDs []int64, accountsByGroup map[int64][]Account, groupNameByID map[int64]string) error {
2356-
currentPlatform := getAccountPlatform(currentAccountPlatform)
2357-
if currentPlatform == "" {
2358-
return nil
2359-
}
2360-
2361-
for _, groupID := range groupIDs {
2362-
accounts := accountsByGroup[groupID]
2363-
for _, account := range accounts {
2364-
if currentAccountID > 0 && account.ID == currentAccountID {
2365-
continue
2366-
}
2367-
2368-
otherPlatform := getAccountPlatform(account.Platform)
2369-
if otherPlatform == "" {
2370-
continue
2371-
}
2372-
2373-
if currentPlatform != otherPlatform {
2374-
groupName := fmt.Sprintf("Group %d", groupID)
2375-
if name := strings.TrimSpace(groupNameByID[groupID]); name != "" {
2376-
groupName = name
2377-
}
2378-
2379-
return &MixedChannelError{
2380-
GroupID: groupID,
2381-
GroupName: groupName,
2382-
CurrentPlatform: currentPlatform,
2383-
OtherPlatform: otherPlatform,
2384-
}
2385-
}
2386-
}
2387-
}
2388-
2389-
return nil
2390-
}
2391-
2392-
func updateMixedChannelPreloadedAccounts(accountsByGroup map[int64][]Account, groupIDs []int64, accountID int64, platform string) {
2393-
if len(groupIDs) == 0 || accountID <= 0 || platform == "" {
2394-
return
2395-
}
2396-
for _, groupID := range groupIDs {
2397-
if groupID <= 0 {
2398-
continue
2399-
}
2400-
accounts := accountsByGroup[groupID]
2401-
found := false
2402-
for i := range accounts {
2403-
if accounts[i].ID != accountID {
2404-
continue
2405-
}
2406-
accounts[i].Platform = platform
2407-
found = true
2408-
break
2409-
}
2410-
if !found {
2411-
accounts = append(accounts, Account{
2412-
ID: accountID,
2413-
Platform: platform,
2414-
})
2415-
}
2416-
accountsByGroup[groupID] = accounts
2417-
}
2418-
}
2419-
24202320
// CheckMixedChannelRisk checks whether target groups contain mixed channels for the current account platform.
24212321
func (s *adminServiceImpl) CheckMixedChannelRisk(ctx context.Context, currentAccountID int64, currentAccountPlatform string, groupIDs []int64) error {
24222322
return s.checkMixedChannelRisk(ctx, currentAccountID, currentAccountPlatform, groupIDs)

0 commit comments

Comments
 (0)