3
0

Cleanup RDBMS code, fix metrics queries

This commit is contained in:
Denis Arh
2022-04-24 09:40:41 +02:00
parent 3e3c4560fb
commit 1c319b7891
3 changed files with 7 additions and 28 deletions
-4
View File
@@ -197,10 +197,6 @@ test.integration.%: $(GOTEST)
test.store: $(GOTEST)
$(GOTEST) $(TEST_FLAGS) $(TEST_SUITE_store)
# Runs one suite from store tests
test.store.%: $(GOTEST)
$(GOTEST) $(TEST_FLAGS) ./store/tests/$*/...
# Runs ALL tests
test.all: $(GOTEST)
$(GOTEST) $(TEST_FLAGS) $(TEST_SUITE_all)
+1 -21
View File
@@ -13,26 +13,6 @@ import (
)
type (
//schemaUpgradeGenerator interface {
// TableExists(string) bool
// CreateTable(t *ddl.Table) string
// CreateIndexes(ii ...*ddl.Index) []string
//}
// Store - Corteza RDBMS persistence layer
//Store struct {
// config *Config
//
// // Schema upgrade generator converts internal upgrade config
// // to implementation specific SQL
// sug schemaUpgradeGenerator
//
// db dbLayer
//
// // Logger for connection
// logger *zap.Logger
//}
dbLayer interface {
sqlx.ExecerContext
SelectContext(context.Context, interface{}, string, ...interface{}) error
@@ -58,7 +38,7 @@ const (
MaxLimit = 1000
)
// Connect is called from the addapter's Connect function
// Connect is called from the adapter's Connect function
//
// It is intentionally not compatible with store.ConnectorFn
// and can not be used to register
+6 -3
View File
@@ -87,10 +87,13 @@ func timestampStatExpr(fields ...string) []interface{} {
valid = []goqu.Expression{}
ee = []interface{}{goqu.COUNT(goqu.Star()).As("total")}
// literal 0 and 1 values we can safely use in the query
lit0, lit1 = goqu.L("0"), goqu.L("1")
sum = func(field string) goqu.Expression {
return goqu.COALESCE(
goqu.SUM(goqu.Case().When(goqu.C(field+"_at").IsNotNull(), 1).Else(0)),
goqu.L("0"),
goqu.SUM(goqu.Case().When(goqu.C(field+"_at").IsNotNull(), lit1).Else(lit0)),
lit0,
).As(field)
}
)
@@ -100,5 +103,5 @@ func timestampStatExpr(fields ...string) []interface{} {
valid = append(valid, goqu.C(field+"_at").IsNull())
}
return append(ee, goqu.SUM(goqu.Case().When(goqu.And(valid...), 1).Else(0)).As("valid"))
return append(ee, goqu.SUM(goqu.Case().When(goqu.And(valid...), lit1).Else(lit0)).As("valid"))
}