PI: Sort pins before display and added extractor production display
This commit is contained in:
parent
c0dfd0563b
commit
d05fd6d9b6
1 changed files with 42 additions and 2 deletions
44
main.go
44
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -264,6 +265,33 @@ func printCharacterInformation(swaggerclient *ESI.App, m *Character) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type byPIPinType []*ESIPlanetaryInteraction.PinsItems0
|
||||||
|
|
||||||
|
func (s byPIPinType) Len() int {
|
||||||
|
return len(s)
|
||||||
|
}
|
||||||
|
func (s byPIPinType) Swap(i, j int) {
|
||||||
|
s[i], s[j] = s[j], s[i]
|
||||||
|
}
|
||||||
|
func (s byPIPinType) Less(i, j int) bool {
|
||||||
|
a := s[i]
|
||||||
|
b := s[j]
|
||||||
|
|
||||||
|
if *a.TypeID != *b.TypeID {
|
||||||
|
return *a.TypeID < *b.TypeID
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.ExtractorDetails != nil {
|
||||||
|
return *a.ExtractorDetails.ProductTypeID < *a.ExtractorDetails.ProductTypeID
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.SchematicID > 0 {
|
||||||
|
return a.SchematicID < b.SchematicID
|
||||||
|
}
|
||||||
|
|
||||||
|
return *a.PinID < *b.PinID
|
||||||
|
}
|
||||||
|
|
||||||
func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
|
func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
|
||||||
|
|
||||||
callParam := ESIPlanetaryInteraction.NewGetCharactersCharacterIDPlanetsParams()
|
callParam := ESIPlanetaryInteraction.NewGetCharactersCharacterIDPlanetsParams()
|
||||||
|
@ -307,7 +335,18 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pin := range pesiresponse.Payload.Pins {
|
pins := pesiresponse.Payload.Pins
|
||||||
|
sort.Sort(byPIPinType(pins))
|
||||||
|
|
||||||
|
ptIds := make([]int32, 0, len(pins))
|
||||||
|
for _, pin := range pins {
|
||||||
|
if pin.ExtractorDetails != nil {
|
||||||
|
ptIds = append(ptIds, *pin.ExtractorDetails.ProductTypeID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pinNames := getUniverseNames(swaggerclient, &ptIds)
|
||||||
|
|
||||||
|
for _, pin := range pins {
|
||||||
if pin.ExtractorDetails != nil {
|
if pin.ExtractorDetails != nil {
|
||||||
status := fmt.Sprint(aurora.Red("✘").Bold())
|
status := fmt.Sprint(aurora.Red("✘").Bold())
|
||||||
statuscomment := fmt.Sprint(aurora.Red("expired").Bold())
|
statuscomment := fmt.Sprint(aurora.Red("expired").Bold())
|
||||||
|
@ -318,9 +357,10 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
|
||||||
duration = time.Time(pin.ExpiryTime).Sub(now)
|
duration = time.Time(pin.ExpiryTime).Sub(now)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" %s Extractor % 5ds cycle, % 6d per cycle, %s %s (%02dd%02d:%02d)\n",
|
fmt.Printf(" %s Extractor % 5ds cycle, %s, % 6d per cycle, %s %s (%02dd%02d:%02d)\n",
|
||||||
status,
|
status,
|
||||||
*pin.ExtractorDetails.CycleTime,
|
*pin.ExtractorDetails.CycleTime,
|
||||||
|
pinNames[*pin.ExtractorDetails.ProductTypeID],
|
||||||
*pin.ExtractorDetails.QtyPerCycle,
|
*pin.ExtractorDetails.QtyPerCycle,
|
||||||
statuscomment,
|
statuscomment,
|
||||||
time.Time(pin.ExpiryTime).Format("_2 Jan 2006, 15:04"),
|
time.Time(pin.ExpiryTime).Format("_2 Jan 2006, 15:04"),
|
||||||
|
|
Reference in a new issue