aboutsummaryrefslogtreecommitdiff
path: root/user/level.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-02-25 16:26:34 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-02-25 16:26:34 +0100
commit443286aabc9d9e433625e0dd99e678754bbc74e5 (patch)
tree1d9011757dcd593cc082fd338732173d3117cf2c /user/level.go
parentdd5a4c1766ed9cadcd5de982f91f407adbd07f40 (diff)
fix(reducer): double call on startup
Diffstat (limited to 'user/level.go')
-rw-r--r--user/level.go12
1 files changed, 6 insertions, 6 deletions
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) {