diff options
| author | William Hergès <william@herges.fr> | 2026-01-17 17:06:38 +0100 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2026-01-17 17:06:38 +0100 |
| commit | 64dfe4ed79022c6a7a00991db7ba679f2dcb3495 (patch) | |
| tree | 607e3964da55f97247b0962de32985c37a750aa0 /user/xp.go | |
| parent | febb77607e81fbb182dd456733ea5adafda44ed4 (diff) | |
refactor(member): better distinction between cached and from database
Diffstat (limited to 'user/xp.go')
| -rw-r--r-- | user/xp.go | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -14,12 +14,12 @@ import ( ) type cXP struct { - Cxp uint - *Copaing + Cxp uint + copaing *Copaing } -func (c *cXP) ToCopaing() *Copaing { - return c.Copaing +func (c *cXP) Copaing() *Copaing { + return c.copaing } func (c *cXP) GetXP() uint { @@ -105,19 +105,13 @@ func GetBestXP(logger *slog.Logger, guildId string, n uint, d int) ([]CopaingAcc logger.Error("fetching xp", "error", err, "copaing", c.ID, "guild", c.GuildID) return } - l = append(l, &cXP{Cxp: xp, Copaing: &c}) + l = append(l, &cXP{Cxp: xp, copaing: &c}) }() } wg.Wait() slices.SortFunc(l, func(a, b *cXP) int { // desc order - if a.Cxp < b.Cxp { - return 1 - } - if a.Cxp > b.Cxp { - return -1 - } - return 0 + return int(b.Cxp) - int(a.Cxp) }) m := min(len(l), int(n)) cs := make([]CopaingAccess, m) |
