Split the name lookup into type and client and ignore "legacy" clients

As explained in the https://developers.eveonline.com/blog/article/universe-names-update blogpost,
there is a range of legacy characters in the 100000000 to 2099999999
range that poses problems and should currently no be resolved using
the universe/names endpoint. We skip them for now.
This commit is contained in:
Thomas Schwery 2017-09-17 22:20:35 +02:00
parent ef2b0ba8ea
commit eb59fd6b48

23
main.go
View file

@ -8,6 +8,8 @@ import (
"golang.org/x/net/context"
"golang.org/x/oauth2"
"runtime/debug"
"io/ioutil"
"net/http"
@ -345,14 +347,16 @@ func printCharacterTransactions(swaggerclient *ESI.App, m *Character) string {
var content string
itemIds := make([]int32, 0)
typeIds := make([]int32, 0)
clientIds := make([]int32, 0)
for _, transaction := range transactions {
itemIds = append(itemIds, *transaction.TypeID)
itemIds = append(itemIds, *transaction.ClientID)
typeIds = append(typeIds, *transaction.TypeID)
clientIds = append(clientIds, *transaction.ClientID)
}
universeNames := getUniverseNames(swaggerclient, &itemIds)
typeNames := getUniverseNames(swaggerclient, &typeIds)
clientNames := getUniverseNames(swaggerclient, &clientIds)
for _, transaction := range transactions[:20] {
@ -372,9 +376,9 @@ func printCharacterTransactions(swaggerclient *ESI.App, m *Character) string {
time.Time(*transaction.Date).Format(defaultDateFormat),
ac.FormatMoney(*transaction.UnitPrice*float32(*transaction.Quantity)),
*transaction.Quantity,
universeNames[*transaction.TypeID],
typeNames[*transaction.TypeID],
locationName.Name,
universeNames[*transaction.ClientID],
clientNames[*transaction.ClientID],
)
content = content + "\n"
@ -751,7 +755,7 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
}
line := fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) (%s) %s",
line := fmt.Sprintf(" %s % 25.25s ISK % 13s ISK % 13s (%s) (%s) %s",
status,
pinNames[*order.TypeID],
ac.FormatMoney(*order.Price),
@ -880,7 +884,9 @@ func getUniverseNames(swaggerclient *ESI.App, itemIds *[]int32) map[int32]string
if len(itemMissingNames) > 0 {
snIds := make([]int32, 0, len(itemMissingNames))
for itemID := range itemMissingNames {
snIds = append(snIds, itemID)
if itemID < 100000000 || itemID > 2099999999 { // cf https://developers.eveonline.com/blog/article/universe-names-update
snIds = append(snIds, itemID)
}
}
sncallParam := ESIUniverse.NewPostUniverseNamesParams()
@ -890,6 +896,7 @@ func getUniverseNames(swaggerclient *ESI.App, itemIds *[]int32) map[int32]string
if skillNameErr != nil {
log.Printf("Error on PostUniverseNames on items: %v\n", snIds)
log.Printf("Error on PostUniverseNames: %s\n", skillNameErr)
log.Printf("Error on PostUniverseNames: %s\n", debug.Stack())
} else {
for _, searchResult := range skillNameResp.Payload {
itemName := searchResult.Name