Requested changes

This commit is contained in:
Caleb Denio 2020-11-21 09:37:14 -05:00
parent a6ecd85fff
commit e3f8dd8ef1

View file

@ -90,7 +90,7 @@ func onMessage(slackClient *slack.Client, event *slackevents.MessageEvent) {
month := now.Month()
// Increment the person's monthly count
redisClient.Incr(fmt.Sprintf("leaderboard:%d-%d:%s", month, year, event.User))
redisClient.Incr(fmt.Sprintf("leaderboard:%d-%d:%s", year, month, event.User))
}
func HandleLeaderboardSlashCommand(w http.ResponseWriter, r *http.Request) {
@ -99,13 +99,13 @@ func HandleLeaderboardSlashCommand(w http.ResponseWriter, r *http.Request) {
year := now.Year()
month := now.Month()
scan := redisClient.Scan(0, fmt.Sprintf("leaderboard:%d-%d:*", month, year), 10)
scan := redisClient.Scan(0, fmt.Sprintf("leaderboard:%d-%d:*", year, month), 10)
if scan.Err() != nil {
w.Write([]byte("Something went wrong while loading the leaderboard :cry: Please try again later!"))
return
}
scan_iterator := scan.Iterator()
scanIterator := scan.Iterator()
type Entry struct {
Number int
@ -114,16 +114,16 @@ func HandleLeaderboardSlashCommand(w http.ResponseWriter, r *http.Request) {
entries := []Entry{}
for scan_iterator.Next() {
entry := redisClient.Get(scan_iterator.Val())
entry_int, err := entry.Int()
for scanIterator.Next() {
entry := redisClient.Get(scanIterator.Val())
entryInt, err := entry.Int()
if err != nil {
return
}
if user, ok := parseLeaderboardEntry(scan_iterator.Val()); ok {
if user, ok := parseLeaderboardEntry(scanIterator.Val()); ok {
entries = append(entries, Entry{
Number: entry_int,
Number: entryInt,
User: user,
})
}