track qualified maps
This commit is contained in:
parent
5351a83762
commit
f002e7c6fb
1 changed files with 31 additions and 0 deletions
|
@ -34,6 +34,8 @@ func RunScraper(config *config.Config, bot *discord.Bot, db *db.Db, api *osuapi.
|
|||
}
|
||||
|
||||
allNewMaps := make(map[int][]osuapi.Beatmapset, 0)
|
||||
|
||||
// add pending maps
|
||||
var newLastUpdateTime = time.Unix(0, 0)
|
||||
for _, beatmapSet := range pendingSets.Beatmapsets {
|
||||
updatedTime, err := time.Parse(time.RFC3339, beatmapSet.LastUpdated)
|
||||
|
@ -60,6 +62,35 @@ func RunScraper(config *config.Config, bot *discord.Bot, db *db.Db, api *osuapi.
|
|||
}
|
||||
}
|
||||
|
||||
// add qualified maps
|
||||
qualifiedSets, err := api.SearchBeatmaps("qualified")
|
||||
if err != nil {
|
||||
log.Println("error fetching pending sets", err)
|
||||
}
|
||||
|
||||
for _, beatmapSet := range qualifiedSets.Beatmapsets {
|
||||
updatedTime, err := time.Parse(time.RFC3339, beatmapSet.LastUpdated)
|
||||
if err != nil {
|
||||
log.Println("error parsing last updated time", updatedTime)
|
||||
}
|
||||
|
||||
if updatedTime.After(newLastUpdateTime) {
|
||||
// update lastUpdateTime to latest updated map
|
||||
newLastUpdateTime = updatedTime
|
||||
}
|
||||
|
||||
if !updatedTime.After(lastUpdateTime) {
|
||||
break
|
||||
}
|
||||
|
||||
mapperId := beatmapSet.UserID
|
||||
if _, ok2 := allNewMaps[mapperId]; !ok2 {
|
||||
allNewMaps[mapperId] = make([]osuapi.Beatmapset, 0)
|
||||
}
|
||||
|
||||
allNewMaps[mapperId] = append(allNewMaps[mapperId], beatmapSet)
|
||||
}
|
||||
|
||||
if len(allNewMaps) > 0 {
|
||||
for mapperId, newMaps := range allNewMaps {
|
||||
channels := make([]string, 0)
|
||||
|
|
Loading…
Reference in a new issue