mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-25 20:15:01 +03:00
ee760de2c8
The client editor gets a "Usage & change history" button: lifetime traffic (every closed cycle plus the open one), usage per node since the last reset, the past cycles, and a log of what changed on the client and from where. A cycle is archived in one place, whenever a traffic reset or an auto-renewal zeroes a client's counters. Both tables are bounded per client: the newest 100 cycles are kept and older ones fold into a single "earlier" row, so the lifetime total does not change; the change log keeps the newest 200 rows and is taken from the stored record before and after an operation (editor save, bulk adjust, bulk enable/disable, bot setters, auto-renewal). A rename moves the history to the new email. The history belongs to the client. Nothing is archived on delete; ReapSyncOrphansJob drops the history of emails no client holds, every five minutes. It lists them outside the traffic writer by walking the email index (about 10 ms on SQLite for 10k clients with 3M history rows) and enters the writer only to delete. Known limit: a client re-created under a deleted client's email before that job runs keeps the old client's history. Edits through an API token are logged with the source "panel".
13 lines
689 B
Go
13 lines
689 B
Go
package model
|
|
|
|
// ClientTrafficWindow is one closed traffic window of a client: usage zeroed at a
|
|
// reset or an auto-renewal; lifetime = SUM(rows) + live counters.
|
|
type ClientTrafficWindow struct {
|
|
Id int64 `json:"id" gorm:"primaryKey;autoIncrement" example:"14825"`
|
|
Email string `json:"email" gorm:"index:idx_client_traffic_window_email,composite:1;not null" example:"user1@example.com"`
|
|
At int64 `json:"at" gorm:"index:idx_client_traffic_window_email,composite:2" example:"1735689600000"`
|
|
Up int64 `json:"up" example:"1048576"`
|
|
Down int64 `json:"down" example:"2097152"`
|
|
Reason string `json:"reason" gorm:"size:16" example:"reset"` // reset | renew | earlier
|
|
}
|