From 06000b7a03d632097ab618d7ae95434c0dcd891d Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 30 May 2026 15:03:13 +0200 Subject: [PATCH] refactor(metrics): drop the user count listener The user count is now counted on demand, so the increment-on-create listener is no longer needed. --- pkg/user/listeners.go | 31 ++++--------------------------- pkg/yaegi_symbols/vikunja_user.go | 1 - 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/pkg/user/listeners.go b/pkg/user/listeners.go index 7fdbe61a3..dfc4a5a2e 100644 --- a/pkg/user/listeners.go +++ b/pkg/user/listeners.go @@ -16,30 +16,7 @@ package user -import ( - "code.vikunja.io/api/pkg/events" - "code.vikunja.io/api/pkg/metrics" - "code.vikunja.io/api/pkg/modules/keyvalue" - "github.com/ThreeDotsLabs/watermill/message" -) - -func RegisterListeners() { - events.RegisterListener((&CreatedEvent{}).Name(), &IncreaseUserCounter{}) -} - -/////// -// User Events - -// IncreaseUserCounter represents a listener -type IncreaseUserCounter struct { -} - -// Name defines the name for the IncreaseUserCounter listener -func (s *IncreaseUserCounter) Name() string { - return "increase.user.counter" -} - -// Handle is executed when the event IncreaseUserCounter listens on is fired -func (s *IncreaseUserCounter) Handle(_ *message.Message) (err error) { - return keyvalue.IncrBy(metrics.UserCountKey, 1) -} +// RegisterListeners registers all event listeners for the user package. +// The user count metric is now counted on demand (see pkg/metrics), so there are +// currently no listeners to register. This hook is kept for future user events. +func RegisterListeners() {} diff --git a/pkg/yaegi_symbols/vikunja_user.go b/pkg/yaegi_symbols/vikunja_user.go index 7ec6a5e3b..86b3aed7a 100644 --- a/pkg/yaegi_symbols/vikunja_user.go +++ b/pkg/yaegi_symbols/vikunja_user.go @@ -159,7 +159,6 @@ func init() { "ErrUsernameReserved": reflect.ValueOf((*user.ErrUsernameReserved)(nil)), "ErrWrongUsernameOrPassword": reflect.ValueOf((*user.ErrWrongUsernameOrPassword)(nil)), "FailedLoginAttemptNotification": reflect.ValueOf((*user.FailedLoginAttemptNotification)(nil)), - "IncreaseUserCounter": reflect.ValueOf((*user.IncreaseUserCounter)(nil)), "InvalidTOTPNotification": reflect.ValueOf((*user.InvalidTOTPNotification)(nil)), "Login": reflect.ValueOf((*user.Login)(nil)), "PasswordAccountLockedAfterInvalidTOTPNotification": reflect.ValueOf((*user.PasswordAccountLockedAfterInvalidTOTPNotification)(nil)),