Browse Source

fix PeriodicTrafficResetJob: log only when there are matching inbound

mhsanaei 13 giờ trước cách đây
mục cha
commit
170d24499e

+ 5 - 1
web/job/periodic_traffic_reset_job.go

@@ -20,12 +20,16 @@ func NewPeriodicTrafficResetJob(period Period) *PeriodicTrafficResetJob {
 
 
 func (j *PeriodicTrafficResetJob) Run() {
 func (j *PeriodicTrafficResetJob) Run() {
 	inbounds, err := j.inboundService.GetInboundsByTrafficReset(string(j.period))
 	inbounds, err := j.inboundService.GetInboundsByTrafficReset(string(j.period))
-	logger.Infof("Running periodic traffic reset job for period: %s", j.period)
 	if err != nil {
 	if err != nil {
 		logger.Warning("Failed to get inbounds for traffic reset:", err)
 		logger.Warning("Failed to get inbounds for traffic reset:", err)
 		return
 		return
 	}
 	}
 
 
+	if len(inbounds) == 0 {
+		return
+	}
+	logger.Infof("Running periodic traffic reset job for period: %s (%d matching inbounds)", j.period, len(inbounds))
+
 	resetCount := 0
 	resetCount := 0
 
 
 	for _, inbound := range inbounds {
 	for _, inbound := range inbounds {