From ad8953adfcc5b4a1ca093ded1f4086b90fa0b8d7 Mon Sep 17 00:00:00 2001 From: Cronus <105345303+ice-cronus@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:20:13 +0700 Subject: [PATCH] fix country update trigger on user modification (#141) --- users/top_countries.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/users/top_countries.go b/users/top_countries.go index bda8810f..557ca78e 100644 --- a/users/top_countries.go +++ b/users/top_countries.go @@ -70,6 +70,10 @@ func (r *repository) updateTotalUsersPerCountryCount(ctx context.Context, usr *U return errors.Wrap(ctx.Err(), "context failed") } } + countryChanged := usr.User != nil && usr.User.ID != "" && usr.Before != nil && usr.Before.ID != "" && usr.User.Country != usr.Before.Country + if !countryChanged { + return nil + } nextIndex := 1 values := make([]string, 0, 1+1) params := make([]any, 0, 1+1)