diff --git a/handlers/getStatus.go b/handlers/getStatus.go index 5d94136..4864da5 100644 --- a/handlers/getStatus.go +++ b/handlers/getStatus.go @@ -12,7 +12,7 @@ import ( ) var initTime = time.Now() -var version = "1.18.3" +var version = "1.18.4" func getStatus(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(map[string]interface{}{ diff --git a/scraper/scrapeGuild.go b/scraper/scrapeGuild.go index f69de43..5ce4145 100644 --- a/scraper/scrapeGuild.go +++ b/scraper/scrapeGuild.go @@ -2,6 +2,7 @@ package scraper import ( "net/http" + "slices" "strconv" "strings" @@ -63,5 +64,15 @@ func scrapeGuild(body *colly.HTMLElement, region, guildName string) { guildProfile.Members = append(guildProfile.Members, member) }) + // Link to master's profile at the top of the page has a different profile target than the one + // in the members list, so replacing it with the one from the members list helps with consistency and cache hits + if guildProfile.Master != nil { + if i := slices.IndexFunc(guildProfile.Members, func(m models.Profile) bool { + return m.FamilyName == guildProfile.Master.FamilyName + }); i != -1 { + guildProfile.Master.ProfileTarget = guildProfile.Members[i].ProfileTarget + } + } + cache.GuildProfiles.AddRecord([]string{region, guildName}, guildProfile, status, body.Request.Ctx.Get("taskId")) }