Add new hourly reset traffic (#3966)
* Add new hourly reset traffic * fix
This commit is contained in:
1 parent
7466916e02
commit
e986a133f8
17 files changed
+28
-1
No files matched your search
@@ -73,6 +73,8 @@
|
||||
:dropdown-class-name="themeSwitcher.currentTheme">
|
||||
<a-select-option value="never">{{ i18n
|
||||
"pages.inbounds.periodicTrafficReset.never" }}</a-select-option>
|
||||
<a-select-option value="hourly">{{ i18n
|
||||
"pages.inbounds.periodicTrafficReset.hourly" }}</a-select-option>
|
||||
<a-select-option value="daily">{{ i18n
|
||||
"pages.inbounds.periodicTrafficReset.daily" }}</a-select-option>
|
||||
<a-select-option value="weekly">{{ i18n
|
||||
|
||||
@@ -37,7 +37,7 @@ func (j *PeriodicTrafficResetJob) Run() {
|
||||
resetCount := 0
|
||||
|
||||
for _, inbound := range inbounds {
|
||||
resetInboundErr := j.inboundService.ResetAllTraffics()
|
||||
resetInboundErr := j.inboundService.ResetInboundTraffic(inbound.Id)
|
||||
if resetInboundErr != nil {
|
||||
logger.Warning("Failed to reset traffic for inbound", inbound.Id, ":", resetInboundErr)
|
||||
}
|
||||
|
||||
@@ -1891,6 +1891,16 @@ func (s *InboundService) ResetAllTraffics() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *InboundService) ResetInboundTraffic(id int) error {
|
||||
db := database.GetDB()
|
||||
|
||||
result := db.Model(model.Inbound{}).
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]any{"up": 0, "down": 0})
|
||||
|
||||
return result.Error
|
||||
}
|
||||
|
||||
func (s *InboundService) DelDepletedClients(id int) (err error) {
|
||||
db := database.GetDB()
|
||||
tx := db.Begin()
|
||||
|
||||
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user