Skip to content

Commit

Permalink
Merge branch 'UnownHash:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuschelCGN authored Sep 18, 2024
2 parents 853f195 + a2348a0 commit 4638eea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
41 changes: 29 additions & 12 deletions decoder/pokestop.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,18 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con

func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(contestData *pogo.GetPokemonSizeLeaderboardEntryOutProto) {
type contestEntry struct {
Rank int `json:"rank"`
Score float64 `json:"score"`
PokemonId int `json:"pokemon_id"`
Form int `json:"form"`
Costume int `json:"costume"`
Gender int `json:"gender"`
Rank int `json:"rank"`
Score float64 `json:"score"`
PokemonId int `json:"pokemon_id"`
Form int `json:"form"`
Costume int `json:"costume"`
Gender int `json:"gender"`
Shiny bool `json:"shiny"`
TempEvolution int `json:"temp_evolution"`
TempEvolutionFinishMs int64 `json:"temp_evolution_finish_ms"`
Alignment int `json:"alignment"`
Badge int `json:"badge"`
LocationCard int `json:"location_card"`
}
type contestJson struct {
TotalEntries int `json:"total_entries"`
Expand All @@ -638,12 +644,23 @@ func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(conte
break
}
j.ContestEntries = append(j.ContestEntries, contestEntry{
Rank: int(rank),
Score: entry.GetScore(),
PokemonId: int(entry.GetPokedexId()),
Form: int(entry.GetPokemonDisplay().Form),
Costume: int(entry.GetPokemonDisplay().Costume),
Gender: int(entry.GetPokemonDisplay().Gender),
Rank: int(rank),
Score: entry.GetScore(),
PokemonId: int(entry.GetPokedexId()),
Form: int(entry.GetPokemonDisplay().Form),
Costume: int(entry.GetPokemonDisplay().Costume),
Gender: int(entry.GetPokemonDisplay().Gender),
Shiny: entry.GetPokemonDisplay().Shiny,
TempEvolution: int(entry.GetPokemonDisplay().CurrentTempEvolution),
TempEvolutionFinishMs: entry.GetPokemonDisplay().TemporaryEvolutionFinishMs,
Alignment: int(entry.GetPokemonDisplay().Alignment),
Badge: int(entry.GetPokemonDisplay().PokemonBadge),
LocationCard: int(func() pogo.LocationCard {
if entry.GetPokemonDisplay().LocationCard == nil {
return 0
}
return entry.GetPokemonDisplay().LocationCard.LocationCard
}()),
})

}
Expand Down
10 changes: 10 additions & 0 deletions decoder/station.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"golbat/db"
"golbat/pogo"
"golbat/util"
"time"

"github.com/jellydator/ttlcache/v3"
Expand Down Expand Up @@ -164,6 +165,15 @@ func hasChangesStation(old *Station, new *Station) bool {
func (station *Station) updateFromStationProto(stationProto *pogo.StationProto, cellId uint64) *Station {
station.Id = stationProto.Id
station.Name = stationProto.Name
// NOTE: Some names have more than 255 runes, which won't fit in our
// varchar(255).
if truncateStr, truncated := util.TruncateUTF8(stationProto.Name, 255); truncated {
log.Warnf("truncating name for station id '%s'. Orig name: %s",
stationProto.Id,
stationProto.Name,
)
station.Name = truncateStr
}
station.Lat = stationProto.Lat
station.Lon = stationProto.Lng
station.StartTime = stationProto.StartTimeMs / 1000
Expand Down
2 changes: 2 additions & 0 deletions sql/32_stations_name.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `station`
CHANGE `name` `name` VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;

0 comments on commit 4638eea

Please sign in to comment.