disable traffic charts if set to zero

This commit is contained in:
Alireza Ahmadi
2025-08-30 02:11:43 +02:00
parent e3c33bf649
commit 560c41acbe
5 changed files with 27 additions and 8 deletions
+7
View File
@@ -391,6 +391,13 @@ func (s *SettingService) Save(tx *gorm.DB, data json.RawMessage) error {
}
}
// Delete all stats if it is set to 0
if key == "trafficAge" && obj == "0" {
err = tx.Where("id > 0").Delete(model.Stats{}).Error
if err != nil {
return err
}
}
err = tx.Model(model.Setting{}).Where("key = ?", key).Update("value", obj).Error
if err != nil {
return err