Fix, again, the total stars calculation
This commit is contained in:
parent
c17b064461
commit
50da41a134
@ -381,6 +381,7 @@ func (s *AoCState) AoCSilentBoardCheckAndUpdate(yr int) {
|
||||
}
|
||||
|
||||
func (s *AoCState) AoCBoardCheckAndUpdate(yr int) {
|
||||
stYr := strconv.Itoa(yr)
|
||||
channelId, _ := s.getChannelId()
|
||||
if s.AoCBoardNeedsUpdate(yr) {
|
||||
l, err := s.aoc.GetLeaderboard(yr)
|
||||
@ -413,11 +414,13 @@ func (s *AoCState) AoCBoardCheckAndUpdate(yr int) {
|
||||
mbrAll := s.getMemberAllYears(v.ID)
|
||||
// Gather all stars from all leaderboards
|
||||
var totalStars int
|
||||
for _, v := range mbrAll {
|
||||
totalStars += v.Stars
|
||||
for k, m := range mbrAll {
|
||||
if k != stYr {
|
||||
totalStars += m.Stars
|
||||
}
|
||||
}
|
||||
// Add this new one into the total
|
||||
allYearsText := fmt.Sprintf(" (%d for all years)", totalStars+1)
|
||||
allYearsText := fmt.Sprintf(" (%d for all years)", totalStars+v.Stars)
|
||||
if yr == s.GetLatestYear() {
|
||||
s.SendSlackMessage(fmt.Sprintf(":christmas_tree: %s now has %d %s! :christmas_tree:%s", v.Name, v.Stars, plural, allYearsText), channelId)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user