From 0373010497232e2c1456cba8710027156d3e1b5b Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Fri, 6 Jun 2025 16:41:48 +0200 Subject: [PATCH] Refactor and fix tagger test --- internal/repository/hooks.go | 4 ++-- internal/repository/stats.go | 2 +- internal/tagger/detectApp_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/repository/hooks.go b/internal/repository/hooks.go index e4fe8e1..4b9e814 100644 --- a/internal/repository/hooks.go +++ b/internal/repository/hooks.go @@ -15,13 +15,13 @@ import ( type Hooks struct{} // Before hook will print the query with it's args and return the context with the timestamp -func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) { +func (h *Hooks) Before(ctx context.Context, query string, args ...any) (context.Context, error) { log.Debugf("SQL query %s %q", query, args) return context.WithValue(ctx, "begin", time.Now()), nil } // After hook will get the timestamp registered on the Before hook and print the elapsed time -func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) { +func (h *Hooks) After(ctx context.Context, query string, args ...any) (context.Context, error) { begin := ctx.Value("begin").(time.Time) log.Debugf("Took: %s\n", time.Since(begin)) return ctx, nil diff --git a/internal/repository/stats.go b/internal/repository/stats.go index 7a5078f..69aa284 100644 --- a/internal/repository/stats.go +++ b/internal/repository/stats.go @@ -686,7 +686,7 @@ func (r *JobRepository) jobsMetricStatisticsHistogram( mainQuery := sq.Select( fmt.Sprintf(`%s + 1 as bin`, binQuery), - fmt.Sprintf(`count(*) as count`), + `count(*) as count`, // For Debug: // fmt.Sprintf(`CAST((%f / %d) as INTEGER ) * %s as min`, peak, *bins, binQuery), // For Debug: // fmt.Sprintf(`CAST((%f / %d) as INTEGER ) * (%s + 1) as max`, peak, *bins, binQuery), ).From("job").Where( diff --git a/internal/tagger/detectApp_test.go b/internal/tagger/detectApp_test.go index 3b43cce..21f3a94 100644 --- a/internal/tagger/detectApp_test.go +++ b/internal/tagger/detectApp_test.go @@ -35,8 +35,8 @@ func TestRegister(t *testing.T) { err := tagger.Register() noErr(t, err) - if len(tagger.apps) != 4 { - t.Errorf("wrong summary for diagnostic \ngot: %d \nwant: 3", len(tagger.apps)) + if len(tagger.apps) != 14 { + t.Errorf("wrong summary for diagnostic \ngot: %d \nwant: 14", len(tagger.apps)) } }