last_star_ts is now an number!
This commit is contained in:
parent
a3d9eb97a9
commit
495a1b6371
16
aoc.go
16
aoc.go
@ -6,8 +6,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -84,17 +82,17 @@ func (a *AoC) fetchLeaderboard(year int) (*Leaderboard, error) {
|
||||
return nil, err
|
||||
}
|
||||
strBody := string(body)
|
||||
strBody = strings.ReplaceAll(strBody, "\"last_star_ts\":0", "\"last_star_ts\":\"0\"")
|
||||
//strBody = strings.ReplaceAll(strBody, "\"last_star_ts\":0", "\"last_star_ts\":\"0\"")
|
||||
err = json.Unmarshal([]byte(strBody), &leaderboard)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, mbr := range leaderboard.Members {
|
||||
starTs, err := strconv.ParseInt(mbr.RawStarTs, 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
mbr.LastStarTs = time.Unix(starTs, 0)
|
||||
//starTs, err := strconv.ParseInt(mbr.RawStarTs, 10, 64)
|
||||
//if err != nil {
|
||||
// continue
|
||||
//}
|
||||
mbr.LastStarTs = time.Unix(mbr.RawStarTs, 0)
|
||||
leaderboard.Members[k] = mbr
|
||||
}
|
||||
leaderboard.LastFetch = time.Now()
|
||||
@ -113,7 +111,7 @@ type Member struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Stars int `json:"stars"`
|
||||
RawStarTs string `json:"last_star_ts"`
|
||||
RawStarTs int64 `json:"last_star_ts"`
|
||||
LocalScore int `json:"local_score"`
|
||||
GlobalScore int `json:"global_score"`
|
||||
LastStarTs time.Time
|
||||
|
Loading…
Reference in New Issue
Block a user