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:
parent
ef2b0ba8ea
commit
eb59fd6b48
1 changed files with 15 additions and 8 deletions
23
main.go
23
main.go
|
@ -8,6 +8,8 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -345,14 +347,16 @@ func printCharacterTransactions(swaggerclient *ESI.App, m *Character) string {
|
||||||
|
|
||||||
var content string
|
var content string
|
||||||
|
|
||||||
itemIds := make([]int32, 0)
|
typeIds := make([]int32, 0)
|
||||||
|
clientIds := make([]int32, 0)
|
||||||
|
|
||||||
for _, transaction := range transactions {
|
for _, transaction := range transactions {
|
||||||
itemIds = append(itemIds, *transaction.TypeID)
|
typeIds = append(typeIds, *transaction.TypeID)
|
||||||
itemIds = append(itemIds, *transaction.ClientID)
|
clientIds = append(clientIds, *transaction.ClientID)
|
||||||
}
|
}
|
||||||
|
|
||||||
universeNames := getUniverseNames(swaggerclient, &itemIds)
|
typeNames := getUniverseNames(swaggerclient, &typeIds)
|
||||||
|
clientNames := getUniverseNames(swaggerclient, &clientIds)
|
||||||
|
|
||||||
for _, transaction := range transactions[:20] {
|
for _, transaction := range transactions[:20] {
|
||||||
|
|
||||||
|
@ -372,9 +376,9 @@ func printCharacterTransactions(swaggerclient *ESI.App, m *Character) string {
|
||||||
time.Time(*transaction.Date).Format(defaultDateFormat),
|
time.Time(*transaction.Date).Format(defaultDateFormat),
|
||||||
ac.FormatMoney(*transaction.UnitPrice*float32(*transaction.Quantity)),
|
ac.FormatMoney(*transaction.UnitPrice*float32(*transaction.Quantity)),
|
||||||
*transaction.Quantity,
|
*transaction.Quantity,
|
||||||
universeNames[*transaction.TypeID],
|
typeNames[*transaction.TypeID],
|
||||||
locationName.Name,
|
locationName.Name,
|
||||||
universeNames[*transaction.ClientID],
|
clientNames[*transaction.ClientID],
|
||||||
)
|
)
|
||||||
|
|
||||||
content = content + "\n"
|
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)
|
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,
|
status,
|
||||||
pinNames[*order.TypeID],
|
pinNames[*order.TypeID],
|
||||||
ac.FormatMoney(*order.Price),
|
ac.FormatMoney(*order.Price),
|
||||||
|
@ -880,7 +884,9 @@ func getUniverseNames(swaggerclient *ESI.App, itemIds *[]int32) map[int32]string
|
||||||
if len(itemMissingNames) > 0 {
|
if len(itemMissingNames) > 0 {
|
||||||
snIds := make([]int32, 0, len(itemMissingNames))
|
snIds := make([]int32, 0, len(itemMissingNames))
|
||||||
for itemID := range 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()
|
sncallParam := ESIUniverse.NewPostUniverseNamesParams()
|
||||||
|
@ -890,6 +896,7 @@ func getUniverseNames(swaggerclient *ESI.App, itemIds *[]int32) map[int32]string
|
||||||
if skillNameErr != nil {
|
if skillNameErr != nil {
|
||||||
log.Printf("Error on PostUniverseNames on items: %v\n", snIds)
|
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", skillNameErr)
|
||||||
|
log.Printf("Error on PostUniverseNames: %s\n", debug.Stack())
|
||||||
} else {
|
} else {
|
||||||
for _, searchResult := range skillNameResp.Payload {
|
for _, searchResult := range skillNameResp.Payload {
|
||||||
itemName := searchResult.Name
|
itemName := searchResult.Name
|
||||||
|
|
Reference in a new issue