Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
fix(loader): fix dr. mundo, remove dots from champion names
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitamet committed Jul 31, 2023
1 parent a00155e commit c3600f1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/lolbuild/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lolbuild
import (
"encoding/json"
"fmt"
"github.com/Nitamet/geemo/backend"
"log"
"net/http"
"strings"
Expand Down Expand Up @@ -118,6 +119,8 @@ func (l *Loader) loadRuneTrees() RuneTrees {

// GetRuneTree returns a rune tree by its name
func (l *Loader) GetRuneTree(name string) RuneTree {
defer backend.LogPanic()

runeTrees := l.loadRuneTrees()

for _, runeTree := range runeTrees {
Expand All @@ -133,6 +136,8 @@ func (l *Loader) GetRuneTree(name string) RuneTree {

// LoadBuilds loads builds for a given champion and role from specified sources
func (l *Loader) LoadBuilds(championName string, sources []string, role string) []BuildCollection {
defer backend.LogPanic()

var wg sync.WaitGroup
builds := make([]BuildCollection, 0)

Expand All @@ -142,12 +147,17 @@ func (l *Loader) LoadBuilds(championName string, sources []string, role string)

for _, source := range sources {
go func(source string) {
defer backend.LogPanic()

results <- *l.loadBuild(championName, source, role)
}(source)
}

go func() {
defer backend.LogPanic()

for result := range results {

builds = append(builds, result)
wg.Done()
}
Expand Down Expand Up @@ -183,9 +193,10 @@ func (l *Loader) loadBuild(championName string, source string, role string) *Bui
return &buildCollection
}

// clearChampionName clears champion name from spaces and apostrophes
// clearChampionName clears champion name from spaces, apostrophes, dots and converts it to lowercase
func (l *Loader) clearChampionName(championName string) string {
clearedChampionName := strings.Replace(championName, "'", "", -1)
clearedChampionName = strings.Replace(clearedChampionName, ".", "", -1)
clearedChampionName = strings.Replace(clearedChampionName, " ", "", -1)
clearedChampionName = strings.ToLower(clearedChampionName)

Expand Down

0 comments on commit c3600f1

Please sign in to comment.