Use redis INCRBY and DECRBY when updating metrics values (#121)
Move test coverage processing to a seperate command Use redis INCRBY and DECRBY when updating metrics values Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/121
This commit is contained in:
parent
9e39399689
commit
3081338a37
3 changed files with 14 additions and 7 deletions
3
Makefile
3
Makefile
|
@ -65,6 +65,9 @@ clean:
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
VIKUNJA_SERVICE_ROOTPATH=$(shell pwd) go test $(GOFLAGS) -cover -coverprofile cover.out $(PACKAGES)
|
VIKUNJA_SERVICE_ROOTPATH=$(shell pwd) go test $(GOFLAGS) -cover -coverprofile cover.out $(PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: test-coverage
|
||||||
|
test-coverage: test
|
||||||
go tool cover -html=cover.out -o cover.html
|
go tool cover -html=cover.out -o cover.html
|
||||||
|
|
||||||
.PHONY: integration-test
|
.PHONY: integration-test
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -59,6 +59,7 @@ require (
|
||||||
github.com/onsi/gomega v1.4.3 // indirect
|
github.com/onsi/gomega v1.4.3 // indirect
|
||||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
||||||
github.com/pelletier/go-toml v1.4.0 // indirect
|
github.com/pelletier/go-toml v1.4.0 // indirect
|
||||||
|
github.com/pkg/errors v0.8.1 // indirect
|
||||||
github.com/prometheus/client_golang v0.9.2
|
github.com/prometheus/client_golang v0.9.2
|
||||||
github.com/samedi/caldav-go v3.0.0+incompatible
|
github.com/samedi/caldav-go v3.0.0+incompatible
|
||||||
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b
|
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b
|
||||||
|
|
|
@ -115,13 +115,16 @@ func UpdateCount(update int64, key string) {
|
||||||
if !config.ServiceEnableMetrics.GetBool() {
|
if !config.ServiceEnableMetrics.GetBool() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
oldtotal, err := GetCount(key)
|
if update > 0 {
|
||||||
if err != nil {
|
err := r.IncrBy(key, update).Err()
|
||||||
log.Error(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
err = SetCount(oldtotal+update, key)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if update < 0 {
|
||||||
|
err := r.DecrBy(key, update).Err()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue