perf: batch fetch proxies for account export

This commit is contained in:
LLLLLLiulei
2026-02-05 18:40:49 +08:00
parent 0c660f8335
commit 0b45d48e85
8 changed files with 77 additions and 3 deletions

View File

@@ -393,8 +393,31 @@ func (h *AccountHandler) resolveExportAccounts(ctx context.Context, ids []int64,
}
func (h *AccountHandler) resolveExportProxies(ctx context.Context, accounts []service.Account) ([]service.Proxy, error) {
_ = accounts
return h.listAllProxies(ctx)
if len(accounts) == 0 {
return []service.Proxy{}, nil
}
seen := make(map[int64]struct{})
ids := make([]int64, 0)
for i := range accounts {
if accounts[i].ProxyID == nil {
continue
}
id := *accounts[i].ProxyID
if id <= 0 {
continue
}
if _, ok := seen[id]; ok {
continue
}
seen[id] = struct{}{}
ids = append(ids, id)
}
if len(ids) == 0 {
return []service.Proxy{}, nil
}
return h.adminService.GetProxiesByIDs(ctx, ids)
}
func parseAccountIDs(c *gin.Context) ([]int64, error) {