From ddd6306752186c149f8ad3bf2f59b5428cf01296 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 8 Mar 2026 13:38:10 +0100 Subject: feat(db): run migrations --- commands/reset.go | 5 ++--- commands/stats.go | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'commands') diff --git a/commands/reset.go b/commands/reset.go index f9c81d2..d18e6ea 100644 --- a/commands/reset.go +++ b/commands/reset.go @@ -3,16 +3,15 @@ package commands import ( "context" - "git.anhgelus.world/anhgelus/les-copaings-bot/common" "git.anhgelus.world/anhgelus/les-copaings-bot/user" "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/interaction" ) func Reset(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand) { - var copaings []*user.Copaing + //var copaings []*user.Copaing //TODO: delete everything from cache - common.GetDB(ctx).Where("guild_id = ?", i.GuildID).Delete(&copaings) + //common.GetDB(ctx).Where("guild_id = ?", i.GuildID).Delete(&copaings) resp := interaction.NewMessageResponse().IsEphemeral().Message("L'XP a été reset.").Response() err := interaction.Respond(i.Interaction, resp).Do(ctx) if err != nil { diff --git a/commands/stats.go b/commands/stats.go index 15f258b..28c0bcc 100644 --- a/commands/stats.go +++ b/commands/stats.go @@ -111,10 +111,10 @@ func Stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman func statsAll(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand, days int) (io.WriterTo, error) { return stats(ctx, dg, i, days, func(before, after string) *gorm.DB { - return common.GetDB(ctx).Raw( + return nil /*common.GetDB(ctx).Raw( before+"WHERE guild_id = ? and created_at > ?"+after, i.GuildID, exp.TimeStampNDaysBefore(ctx, uint(days)), - ) + )*/ }) } @@ -124,10 +124,10 @@ func statsMember(ctx context.Context, dg bot.Session, i *interaction.Application return nil, err } return stats(ctx, dg, i, days, func(before, after string) *gorm.DB { - return common.GetDB(ctx).Raw( + return nil /*common.GetDB(ctx).Raw( before+"WHERE guild_id = ? and created_at > ? and copaing_id = ?"+after, i.GuildID, exp.TimeStampNDaysBefore(ctx, uint(days)), user.GetCopaing(ctx, discordID, i.GuildID).ID, - ) + )*/ }) } @@ -171,7 +171,7 @@ func stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman for _, raw := range rawData { _, ok := copaings[raw.CopaingID] if !ok { - var cp user.Copaing + /*var cp user.Copaing if err := common.GetDB(ctx).First(&cp, raw.CopaingID).Error; err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { bot.Logger(ctx).Error("finding copaing", "error", err, "copaing", raw.CopaingID) @@ -180,7 +180,7 @@ func stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman bot.Logger(ctx).Warn("copaing not found, skipping", "copaing", raw.CopaingID) continue } - copaings[raw.CopaingID] = &cp + copaings[raw.CopaingID] = &cp*/ } pts, ok := stats[raw.CopaingID] now := time.Now().Unix() -- cgit v1.2.3