Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fail on non-success gohbem init #254

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions decoder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ func InitialiseOhbem() {
}

gohbemLogger := &gohbemLogger{}

cacheFileLocation := "cache/master-latest-basics.json"
o := &gohbem.Ohbem{Leagues: leagues, LevelCaps: config.Config.Pvp.LevelCaps,
IncludeHundosUnderCap: config.Config.Pvp.IncludeHundosUnderCap, Logger: gohbemLogger}
IncludeHundosUnderCap: config.Config.Pvp.IncludeHundosUnderCap,
MasterFileCachePath: cacheFileLocation, Logger: gohbemLogger}
switch config.Config.Pvp.RankingComparator {
case "prefer_higher_cp":
o.RankingComparator = gohbem.RankingComparatorPreferHigherCp
Expand All @@ -197,8 +198,16 @@ func InitialiseOhbem() {
}

if err := o.FetchPokemonData(); err != nil {
log.Errorf("ohbem.FetchPokemonData: %s", err)
return
if err2 := o.LoadPokemonData(cacheFileLocation); err2 != nil {
_ = o.LoadPokemonData("pogo/master-latest-basics.json")
log.Errorf("ohbem.FetchPokemonData failed. ohbem.LoadPokemonData from cache failed: %s. Loading from pogo/master-latest-basics.json instead.", err2)
} else {
log.Warnf("ohbem.FetchPokemonData failed, loaded from cache: %s", err)
}
}

if o.PokemonData.Initialized == true {
_ = o.SavePokemonData(cacheFileLocation)
}

_ = o.WatchPokemonData()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.23.2

require (
github.com/Depado/ginprom v1.8.1
github.com/UnownHash/gohbem v0.11.3
github.com/UnownHash/gohbem v0.12.0
github.com/getsentry/sentry-go v0.29.1
github.com/gin-gonic/gin v1.10.0
github.com/go-sql-driver/mysql v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/UnownHash/gohbem v0.11.3 h1:ffl+EMsp74GoSReJ+O2LSFwTeBVL/vHRnz0Yf6h77GY=
github.com/UnownHash/gohbem v0.11.3/go.mod h1:I7SrAlxOo56fGlUD7pLtitcGcmRd7rr9/HWpgmseqSc=
github.com/UnownHash/gohbem v0.12.0 h1:eSyioEWJSU/81i6wf5x4XaiRZBXm6dW/KuYiHKjcELI=
github.com/UnownHash/gohbem v0.12.0/go.mod h1:PUeicvRH6HyjTgkuaivjYHzDUzErf2QlsXZ24m0DaNU=
github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4=
github.com/appleboy/gofight/v2 v2.1.2/go.mod h1:frW+U1QZEdDgixycTj4CygQ48yLTUhplt43+Wczp3rw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
Loading
Loading