Fix nil pointer dereference and add filtering of skill queue
This commit is contained in:
parent
c1f48b56ed
commit
74e6f41998
2 changed files with 31 additions and 23 deletions
|
@ -513,7 +513,7 @@ func (a *Client) PostUniverseNames(params *PostUniverseNamesParams) (*PostUniver
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
PathPattern: "/universe/names/",
|
PathPattern: "/universe/names/",
|
||||||
ProducesMediaTypes: []string{"application/json"},
|
ProducesMediaTypes: []string{"application/json"},
|
||||||
ConsumesMediaTypes: []string{""},
|
ConsumesMediaTypes: []string{"application/json"},
|
||||||
Schemes: []string{"https"},
|
Schemes: []string{"https"},
|
||||||
Params: params,
|
Params: params,
|
||||||
Reader: &PostUniverseNamesReader{formats: a.formats},
|
Reader: &PostUniverseNamesReader{formats: a.formats},
|
||||||
|
|
18
main.go
18
main.go
|
@ -117,7 +117,7 @@ func getCharacterSkillQueue(client *http.Client, m *Character) {
|
||||||
skillMissingNames := make(map[int32]string)
|
skillMissingNames := make(map[int32]string)
|
||||||
|
|
||||||
for _, skill := range skillqueue {
|
for _, skill := range skillqueue {
|
||||||
skillName := getCachedData(fmt.Sprintf("%d.name", skill.SkillID))
|
skillName := getCachedData(fmt.Sprintf("%d.name", *skill.SkillID))
|
||||||
if skillName != "" {
|
if skillName != "" {
|
||||||
skillNames[*skill.SkillID] = skillName
|
skillNames[*skill.SkillID] = skillName
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,6 +125,7 @@ func getCharacterSkillQueue(client *http.Client, m *Character) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(skillMissingNames) > 0 {
|
||||||
snIds := make([]int32, 0, len(skillMissingNames))
|
snIds := make([]int32, 0, len(skillMissingNames))
|
||||||
for skillID := range skillMissingNames {
|
for skillID := range skillMissingNames {
|
||||||
snIds = append(snIds, skillID)
|
snIds = append(snIds, skillID)
|
||||||
|
@ -145,20 +146,27 @@ func getCharacterSkillQueue(client *http.Client, m *Character) {
|
||||||
itemName := searchResult.Name
|
itemName := searchResult.Name
|
||||||
itemID := searchResult.ID
|
itemID := searchResult.ID
|
||||||
|
|
||||||
log.Printf("Got search result %d -> %s", *itemID, *itemName)
|
|
||||||
|
|
||||||
putCacheData(fmt.Sprintf("%d.name", *itemID), *itemName)
|
putCacheData(fmt.Sprintf("%d.name", *itemID), *itemName)
|
||||||
|
|
||||||
skillNames[*itemID] = *itemName
|
skillNames[*itemID] = *itemName
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, skill := range skillqueue {
|
for _, skill := range skillqueue {
|
||||||
// element is the element from someSlice for where we are
|
// element is the element from someSlice for where we are
|
||||||
name := skillNames[*skill.SkillID]
|
name := skillNames[*skill.SkillID]
|
||||||
|
|
||||||
fmt.Printf(" %s: %d, level %d - %s to %s\n",
|
finishDate := time.Time(skill.FinishDate)
|
||||||
|
|
||||||
|
// see https://github.com/ccpgames/esi-issues/issues/113
|
||||||
|
// The queue is only updated when the user logs in with the client
|
||||||
|
// we thus need to do the computations and filtering ourselves
|
||||||
|
if finishDate.Before(time.Now()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf(" %s - level %d - %s to %s\n",
|
||||||
name,
|
name,
|
||||||
*skill.SkillID,
|
|
||||||
*skill.FinishedLevel,
|
*skill.FinishedLevel,
|
||||||
time.Time(skill.StartDate).Format("_2 Jan 2006, 15:04"),
|
time.Time(skill.StartDate).Format("_2 Jan 2006, 15:04"),
|
||||||
time.Time(skill.FinishDate).Format("_2 Jan 2006, 15:04"))
|
time.Time(skill.FinishDate).Format("_2 Jan 2006, 15:04"))
|
||||||
|
|
Reference in a new issue