diff options
| -rw-r--r-- | commands/stats.go | 30 | ||||
| -rw-r--r-- | exp/functions.go | 2 |
2 files changed, 19 insertions, 13 deletions
diff --git a/commands/stats.go b/commands/stats.go index ccc5857..5d22483 100644 --- a/commands/stats.go +++ b/commands/stats.go @@ -128,17 +128,20 @@ func statsAll(s *discordgo.Session, i *discordgo.InteractionCreate, days uint) ( } pts, ok := stats[raw.CopaingID] if !ok { - pts = &[]plotter.XY{} + t := make([]plotter.XY, days) + pts = &t stats[raw.CopaingID] = pts } - t := float64(raw.CreatedAt.Unix() - time.Now().Unix()) + t := raw.CreatedAt.Unix() - time.Now().Unix() if !gokord.Debug { - t = math.Ceil(t / (24 * 60 * 60)) + t = int64(math.Ceil(float64(t) / (24 * 60 * 60))) + } else { + t = int64(math.Ceil(float64(t) / 6)) } - *pts = append(*pts, plotter.XY{ - X: t, + (*pts)[t] = plotter.XY{ + X: float64(t), Y: float64(raw.XP), - }) + } } return generatePlot(s, i, days, copaings, stats) @@ -194,17 +197,20 @@ func statsMember(s *discordgo.Session, i *discordgo.InteractionCreate, days uint for _, raw := range rawData { pts, ok := stats[raw.CopaingID] if !ok { - pts = &[]plotter.XY{} + t := make([]plotter.XY, days) + pts = &t stats[raw.CopaingID] = pts } - t := float64(raw.CreatedAt.Unix() - time.Now().Unix()) + t := raw.CreatedAt.Unix() - time.Now().Unix() if !gokord.Debug { - t = math.Ceil(t / (24 * 60 * 60)) + t = int64(math.Ceil(float64(t) / (24 * 60 * 60))) + } else { + t = int64(math.Ceil(float64(t) / 6)) } - *pts = append(*pts, plotter.XY{ - X: t, + (*pts)[t] = plotter.XY{ + X: float64(t), Y: float64(raw.XP), - }) + } } return generatePlot(s, i, days, copaings, stats) diff --git a/exp/functions.go b/exp/functions.go index a8b0350..ebd0761 100644 --- a/exp/functions.go +++ b/exp/functions.go @@ -53,7 +53,7 @@ func LevelXP(level uint) uint { func TimeStampNDaysBefore(n uint) string { var unix time.Time if gokord.Debug { - unix = time.Unix(time.Now().Unix()-int64(n)*6, 0) // reduce time for debug + unix = time.Unix(time.Now().Unix()-int64(n*6), 0) // reduce time for debug } else { unix = time.Unix(time.Now().Unix()-int64(n*24*60*60), 0) } |
