fix: correct log message for completed periodic traffic reset

This commit is contained in:
egregors 2025-09-14 11:27:42 +02:00
parent 6fce769c27
commit ec7f28179c
No known key found for this signature in database
GPG key ID: 78C8DDCC8BB0494A
3 changed files with 4 additions and 8 deletions

View file

@ -39,6 +39,6 @@ func (j *PeriodicTrafficResetJob) Run() {
}
if resetCount > 0 {
logger.Infof("Periodic traffic reset completed: %d inbounds reset", resetCount)
logger.Infof("Periodic traffic reset completed: %d inbounds reseted", resetCount)
}
}

View file

@ -44,12 +44,10 @@ func (s *InboundService) GetAllInbounds() ([]*model.Inbound, error) {
func (s *InboundService) GetInboundsByTrafficReset(period string) ([]*model.Inbound, error) {
db := database.GetDB()
var inbounds []*model.Inbound
logger.Info("Fetching inbounds with traffic reset period:", period)
err := db.Model(model.Inbound{}).Where("traffic_reset = ?", period).Find(&inbounds).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
logger.Infof("Found %d inbounds with traffic reset period: %s", len(inbounds), period)
return inbounds, nil
}

View file

@ -271,19 +271,17 @@ func (s *Server) startTask() {
{
// Inbound traffic reset jobs
// Run once a day, midnight
// TODO: for testing, run every minute, change back to daily later
// s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily"))
s.cron.AddJob("@every 10s", job.NewPeriodicTrafficResetJob("daily"))
s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily"))
// Run once a week, midnight between Sat/Sun
s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly"))
// Run once a month, midnight, first of month
s.cron.AddJob("@monthly", job.NewPeriodicTrafficResetJob("monthly"))
// Client traffic reset jobs
// TODO: Client traffic reset jobs
// logger.Info("Scheduling periodic client traffic reset jobs")
// Run once a day, midnight
// TODO: for testing, run every minute, change back to daily later
// s.cron.AddJob("@daily", job.NewPeriodicClientTrafficResetJob("daily"))
// s.cron.AddJob("@every 10s", job.NewPeriodicClientTrafficResetJob("daily"))
// s.cron.AddJob("* * * * *", job.NewPeriodicClientTrafficResetJob("daily"))
// Run once a week, midnight between Sat/Sun
// s.cron.AddJob("@weekly", job.NewPeriodicClientTrafficResetJob("weekly"))