add outbound traffic reset (#1767)

This commit is contained in:
surbiks
2024-02-07 11:25:31 +03:30
committed by GitHub
parent 6cf29d5145
commit 13de2c6ca0
3 changed files with 52 additions and 2 deletions

View File

@@ -78,3 +78,25 @@ func (s *OutboundService) GetOutboundsTraffic() ([]*model.OutboundTraffics, erro
return traffics, nil
}
func (s *OutboundService) ResetOutboundTraffic(tag string) error {
db := database.GetDB()
whereText := "tag "
if tag == "-alltags-" {
whereText += " <> ?"
} else {
whereText += " = ?"
}
result := db.Model(model.OutboundTraffics{}).
Where(whereText, tag).
Updates(map[string]interface{}{"up": 0, "down": 0, "total": 0})
err := result.Error
if err != nil {
return err
}
return nil
}