[PR #6469] [MERGED] feat(clients): preserve traffic counters in portable export/import #6292

Closed
opened 2026-11-02 04:07:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6469
Author: @mrchatam
Created: 9/11/2026
Status: ✅ Merged
Merged: 9/27/2026
Merged by: @MHSanaei

Base: main ← Head: feat/portable-clients-preserve-traffic


📝 Commits (5)

  • 7efa159 feat(clients): preserve traffic counters in portable export/import
  • 5c43233 Merge remote-tracking branch 'origin/main' into pr/6469
  • a3a9b12 Merge branch 'main' into feat/portable-clients-preserve-traffic
  • 6c82a3c fix(clients): restore imported traffic only onto rows the import created
  • 70eedb2 fix(groups): keep imported traffic out of group totals

📊 Changes

11 files changed (+551 additions, -69 deletions)

View changed files

📝 docs/content/docs/en/reference/api/clients.mdx (+38 -26)
📝 docs/public/openapi.json (+9 -3)
📝 frontend/public/openapi.json (+9 -3)
📝 frontend/src/pages/api-docs/endpoints.ts (+3 -3)
📝 internal/web/controller/client.go (+8 -4)
📝 internal/web/controller/client_partial_apply_test.go (+51 -0)
📝 internal/web/service/client.go (+12 -7)
📝 internal/web/service/client_bulk.go (+20 -6)
📝 internal/web/service/client_groups.go (+13 -3)
📝 internal/web/service/client_portable.go (+100 -14)
📝 internal/web/service/client_portable_test.go (+288 -0)

📄 Description

Summary

  • Portable client export now includes a traffic snapshot from client_traffics (up/down/total, plus resetCount/lastOnline/lastSubFetch).
  • Import restores those counters only for newly created emails; skipped or already-present emails keep their live usage untouched.
  • Legacy export files without traffic keep the previous zero-start behavior.

Fixes #5858

Test plan

  • go test ./internal/web/service/ -run 'TestExportImportPreservesTrafficCounters|TestImportClientsAppliesTrafficForOrphans' -count=1
  • Export clients from a panel with non-zero usage, import into a fresh panel, confirm up/down match
  • Re-import the same file into a panel where those emails already exist; confirm live counters are unchanged

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6469 **Author:** [@mrchatam](https://github.com/mrchatam) **Created:** 9/11/2026 **Status:** ✅ Merged **Merged:** 9/27/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/portable-clients-preserve-traffic` --- ### 📝 Commits (5) - [`7efa159`](https://github.com/MHSanaei/3x-ui/commit/7efa159a29fa942052557573f2d0a8a14d4a2398) feat(clients): preserve traffic counters in portable export/import - [`5c43233`](https://github.com/MHSanaei/3x-ui/commit/5c4323300e43e6241983fa97fd214e08bf76f871) Merge remote-tracking branch 'origin/main' into pr/6469 - [`a3a9b12`](https://github.com/MHSanaei/3x-ui/commit/a3a9b12c3c82956b00f3cd44ff85d23e20be635b) Merge branch 'main' into feat/portable-clients-preserve-traffic - [`6c82a3c`](https://github.com/MHSanaei/3x-ui/commit/6c82a3c9d72442cff826aca7652aa1c7e59d5c64) fix(clients): restore imported traffic only onto rows the import created - [`70eedb2`](https://github.com/MHSanaei/3x-ui/commit/70eedb249ae360385a8c6ea247edd42a28543216) fix(groups): keep imported traffic out of group totals ### 📊 Changes **11 files changed** (+551 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/clients.mdx` (+38 -26) 📝 `docs/public/openapi.json` (+9 -3) 📝 `frontend/public/openapi.json` (+9 -3) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+3 -3) 📝 `internal/web/controller/client.go` (+8 -4) 📝 `internal/web/controller/client_partial_apply_test.go` (+51 -0) 📝 `internal/web/service/client.go` (+12 -7) 📝 `internal/web/service/client_bulk.go` (+20 -6) 📝 `internal/web/service/client_groups.go` (+13 -3) 📝 `internal/web/service/client_portable.go` (+100 -14) 📝 `internal/web/service/client_portable_test.go` (+288 -0) </details> ### 📄 Description ## Summary - Portable client export now includes a `traffic` snapshot from `client_traffics` (`up`/`down`/`total`, plus `resetCount`/`lastOnline`/`lastSubFetch`). - Import restores those counters only for **newly created** emails; skipped or already-present emails keep their live usage untouched. - Legacy export files without `traffic` keep the previous zero-start behavior. Fixes #5858 ## Test plan - [x] `go test ./internal/web/service/ -run 'TestExportImportPreservesTrafficCounters|TestImportClientsAppliesTrafficForOrphans' -count=1` - [ ] Export clients from a panel with non-zero usage, import into a fresh panel, confirm up/down match - [ ] Re-import the same file into a panel where those emails already exist; confirm live counters are unchanged --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:44 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6292
No description provided.