Add station name to the market orders
This commit is contained in:
parent
4088dfb25b
commit
44fb43a8e9
1 changed files with 32 additions and 30 deletions
62
main.go
62
main.go
|
@ -358,7 +358,7 @@ func printCharacterInformation(swaggerclient *ESI.App, m *Character) string {
|
|||
}
|
||||
|
||||
if position.StructureID != nil {
|
||||
retName, retErr := getStructureStationInfo(swaggerclient, "structure", *position.StructureID)
|
||||
retName, retErr := getStructureStationInfo(swaggerclient, *position.StructureID)
|
||||
if retErr == nil {
|
||||
stationName = retName.Name
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ func printClonesInformation(swaggerclient *ESI.App, m *Character) string {
|
|||
clones := cloresponse.Payload.JumpClones
|
||||
|
||||
for _, clone := range clones {
|
||||
sInfo, sErr := getStructureStationInfo(swaggerclient, clone.LocationType, clone.LocationID)
|
||||
sInfo, sErr := getStructureStationInfo(swaggerclient, clone.LocationID)
|
||||
if sErr != nil {
|
||||
fmt.Printf("Error on structure information read on structure %s\n", clone.LocationID)
|
||||
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
||||
|
@ -418,7 +418,7 @@ type structureInfo struct {
|
|||
System solarSystemInfo
|
||||
}
|
||||
|
||||
func getStructureStationInfo(swaggerclient *ESI.App, typeID string, ID int64) (*structureInfo, error) {
|
||||
func getStructureStationInfo(swaggerclient *ESI.App, ID int64) (*structureInfo, error) {
|
||||
locationName := cache.GetCachedDataSub64(ID, "name")
|
||||
locationSystem := cache.GetCachedDataIntSub64(ID, "system")
|
||||
|
||||
|
@ -432,7 +432,7 @@ func getStructureStationInfo(swaggerclient *ESI.App, typeID string, ID int64) (*
|
|||
return &sInfo, nil
|
||||
}
|
||||
|
||||
if typeID == "station" {
|
||||
if ID <= 1000000000000 {
|
||||
stacallParams := ESIUniverse.NewGetUniverseStationsStationIDParams()
|
||||
stacallParams.WithStationID(int32(ID))
|
||||
|
||||
|
@ -457,32 +457,28 @@ func getStructureStationInfo(swaggerclient *ESI.App, typeID string, ID int64) (*
|
|||
return &sInfo, nil
|
||||
}
|
||||
|
||||
if typeID == "structure" {
|
||||
strcallParams := ESIUniverse.NewGetUniverseStructuresStructureIDParams()
|
||||
strcallParams.WithStructureID(ID)
|
||||
strcallParams := ESIUniverse.NewGetUniverseStructuresStructureIDParams()
|
||||
strcallParams.WithStructureID(ID)
|
||||
|
||||
strresponse, strerr := swaggerclient.Universe.GetUniverseStructuresStructureID(strcallParams, nil)
|
||||
if strerr != nil {
|
||||
log.Printf("Got error on GetUniverseStructuresStructureID: %s", strerr)
|
||||
return nil, strerr
|
||||
}
|
||||
|
||||
strInfo := strresponse.Payload
|
||||
|
||||
var sInfo structureInfo
|
||||
|
||||
sInfo.ID = ID
|
||||
sInfo.Name = *strInfo.Name
|
||||
sInfo.SystemID = *strInfo.SolarSystemID
|
||||
sInfo.System = getSolarSystemInformation(swaggerclient, sInfo.SystemID)
|
||||
|
||||
cache.PutCacheDataSub64(sInfo.ID, "name", sInfo.Name)
|
||||
cache.PutCacheDataIntSub64(sInfo.ID, "system", sInfo.SystemID)
|
||||
|
||||
return &sInfo, nil
|
||||
strresponse, strerr := swaggerclient.Universe.GetUniverseStructuresStructureID(strcallParams, nil)
|
||||
if strerr != nil {
|
||||
log.Printf("Got error on GetUniverseStructuresStructureID: %s", strerr)
|
||||
return nil, strerr
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
strInfo := strresponse.Payload
|
||||
|
||||
var sInfo structureInfo
|
||||
|
||||
sInfo.ID = ID
|
||||
sInfo.Name = *strInfo.Name
|
||||
sInfo.SystemID = *strInfo.SolarSystemID
|
||||
sInfo.System = getSolarSystemInformation(swaggerclient, sInfo.SystemID)
|
||||
|
||||
cache.PutCacheDataSub64(sInfo.ID, "name", sInfo.Name)
|
||||
cache.PutCacheDataIntSub64(sInfo.ID, "system", sInfo.SystemID)
|
||||
|
||||
return &sInfo, nil
|
||||
}
|
||||
|
||||
type byPIPinType []*ESIPlanetaryInteraction.PinsItems0
|
||||
|
@ -636,7 +632,7 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
|||
buySellStatus = "↡"
|
||||
}
|
||||
|
||||
status := ""
|
||||
var status string
|
||||
|
||||
if remainingDuration.Hours() <= 0 {
|
||||
status = fmt.Sprint(aurora.Red(buySellStatus).Bold())
|
||||
|
@ -656,13 +652,19 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
|||
quantity = fmt.Sprint(aurora.Green(quantity))
|
||||
}
|
||||
|
||||
content = content + fmt.Sprintf(" %s % 25.25s ISK % 12s %s ISK % 13s (%s)\n",
|
||||
sInfo, sErr := getStructureStationInfo(swaggerclient, int64(*order.LocationID))
|
||||
if sErr != nil {
|
||||
fmt.Printf("Error on structure information read on structure %s\n", order.LocationID)
|
||||
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
||||
}
|
||||
|
||||
content = content + fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) %s\n",
|
||||
status,
|
||||
pinNames[*order.TypeID],
|
||||
ac.FormatMoney(*order.Price),
|
||||
expirationDate.Format(defaultDateFormat),
|
||||
ac.FormatMoney(remainingAmount),
|
||||
quantity,
|
||||
sInfo.Name,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue