Skip to content

Commit

Permalink
Merge pull request #200 from UnownHash/pokestop_name
Browse files Browse the repository at this point in the history
Support pokestop_name in pokemon webhook
  • Loading branch information
Fabio1988 authored Mar 31, 2024
2 parents 9b32dac + 1e84e37 commit 89c3b71
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions decoder/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func savePokemonRecordAsAtTime(ctx context.Context, db db.DbDetails, pokemon *Po
updatePokemonLookup(pokemon, changePvpField, pvpResults)

areas := MatchStatsGeofence(pokemon.Lat, pokemon.Lon)
createPokemonWebhooks(oldPokemon, pokemon, areas)
createPokemonWebhooks(ctx, db, oldPokemon, pokemon, areas)
updatePokemonStats(oldPokemon, pokemon, areas)
updatePokemonNests(oldPokemon, pokemon)

Expand All @@ -399,7 +399,7 @@ func savePokemonRecordAsAtTime(ctx context.Context, db db.DbDetails, pokemon *Po
}
}

func createPokemonWebhooks(old *Pokemon, new *Pokemon, areas []geo.AreaName) {
func createPokemonWebhooks(ctx context.Context, db db.DbDetails, old *Pokemon, new *Pokemon, areas []geo.AreaName) {
//nullString := func (v null.Int) interface{} {
// if !v.Valid {
// return "null"
Expand All @@ -425,6 +425,18 @@ func createPokemonWebhooks(old *Pokemon, new *Pokemon, areas []geo.AreaName) {
return new.PokestopId.ValueOrZero()
}
}(),
"pokestop_name": func() *string {
if !new.PokestopId.Valid {
return nil
} else {
pokestop, _ := GetPokestopRecord(ctx, db, new.PokestopId.String)
name := "Unknown"
if pokestop != nil {
name = pokestop.Name.ValueOrZero()
}
return &name
}
}(),
"encounter_id": new.Id,
"pokemon_id": new.PokemonId,
"latitude": new.Lat,
Expand Down

0 comments on commit 89c3b71

Please sign in to comment.