From 13de2c6ca0d9101d247a81aa06dddbf338441703 Mon Sep 17 00:00:00 2001 From: surbiks <43953720+surbiks@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:25:31 +0330 Subject: add outbound traffic reset (#1767) --- web/service/outbound.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'web/service') diff --git a/web/service/outbound.go b/web/service/outbound.go index dc0e0742..244d7a14 100644 --- a/web/service/outbound.go +++ b/web/service/outbound.go @@ -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 +} -- cgit v1.2.3