From 443286aabc9d9e433625e0dd99e678754bbc74e5 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Wed, 25 Feb 2026 16:26:34 +0100 Subject: fix(reducer): double call on startup --- user/level.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'user') diff --git a/user/level.go b/user/level.go index 0b839d1..2a5d494 100644 --- a/user/level.go +++ b/user/level.go @@ -51,25 +51,25 @@ func (c *CopaingCached) onNewLevel(ctx context.Context, dg bot.Session, level ui func PeriodicReducer(ctx context.Context, dg bot.Session) { PeriodicSaver(ctx, dg) - logger := bot.Logger(ctx) - logger.Debug("periodic reducer") + log := bot.Logger(ctx) + log.Debug("periodic reducer") state := GetState(ctx) n := 0 var wg sync.WaitGroup for _, g := range dg.GuildAPI().State.Guilds() { - n++ cfg := config.GetGuildConfig(ctx, g) res := common.GetDB(ctx). Model(&CopaingXP{}). Where("guild_id = ? and created_at < ?", g, exp.TimeStampNDaysBefore(ctx, cfg.DaysXPRemains)). Delete(&CopaingXP{}) if res.Error != nil { - logger.Error("removing old xp", "error", res.Error, "guild", g) + log.Error("removing old xp", "error", res.Error, "guild", g) continue } - logger.Debug("guild cleaned", "guild", g, "rows affected", res.RowsAffected) + n++ + log.Debug("guild cleaned", "guild", g, "rows affected", res.RowsAffected) wg.Go(func() { syncCopaings(ctx, dg, state.Copaings(g)) @@ -78,7 +78,7 @@ func PeriodicReducer(ctx context.Context, dg bot.Session) { wg.Wait() - logger.Debug("periodic reduce finished", "guilds affected", n) + log.Debug("periodic reduce finished", "guilds affected", n) } func syncCopaings(ctx context.Context, dg bot.Session, ccs []CopaingCached) { -- cgit v1.2.3