Rebuild clears the index and repopulates it from every user record on disk plus all currently online users. Only active character names are added here; the alt-characters module is responsible for adding alt names after this runs.
()
| 74 | // the alt-characters module is responsible for adding alt names after this |
| 75 | // runs. |
| 76 | func (ci *CharacterIndex) Rebuild() { |
| 77 | newMap := make(map[string]int) |
| 78 | |
| 79 | SearchOfflineUsers(func(u *UserRecord) bool { |
| 80 | if u.Character != nil && u.Character.Name != "" { |
| 81 | newMap[strings.ToLower(u.Character.Name)] = u.UserId |
| 82 | } |
| 83 | return true |
| 84 | }) |
| 85 | |
| 86 | for _, u := range GetAllActiveUsers() { |
| 87 | if u.Character != nil && u.Character.Name != "" { |
| 88 | newMap[strings.ToLower(u.Character.Name)] = u.UserId |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | ci.mu.Lock() |
| 93 | ci.byName = newMap |
| 94 | ci.mu.Unlock() |
| 95 | } |
nothing calls this directly
no test coverage detected