add some new files and services add hwtools that shows the current and last GWs - not yet included the user stats (if any available)
46 lines
889 B
Go
46 lines
889 B
Go
package datacollector
|
|
|
|
import (
|
|
"hwcollector/server/models"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func init() {
|
|
processes["arenaFindEnemies"] = new(DoArenaFindEnemies)
|
|
}
|
|
|
|
// DoArenaFindEnemies ...
|
|
type DoArenaFindEnemies struct {
|
|
data []byte
|
|
}
|
|
|
|
// Start ...
|
|
func (x *DoArenaFindEnemies) Start() {
|
|
}
|
|
|
|
// SetJSONByte ...
|
|
func (x *DoArenaFindEnemies) SetJSONByte(b []byte) {
|
|
x.data = b
|
|
}
|
|
|
|
// SetJSON ...
|
|
func (x *DoArenaFindEnemies) SetJSON(s string) {
|
|
x.data = []byte(s)
|
|
}
|
|
|
|
// GetUserDetails ...
|
|
func (x *DoArenaFindEnemies) GetUserDetails() ([]*models.User, error) {
|
|
var users []*models.User
|
|
|
|
result := gjson.GetBytes(x.data, "response.result.response.enemies.#.user")
|
|
for _, jsonValue := range result.Array() {
|
|
user := new(models.User)
|
|
if err := user.UnmarshalUserJSON([]byte(jsonValue.Raw)); err != nil {
|
|
return nil, err
|
|
}
|
|
users = append(users, user)
|
|
}
|
|
return users, nil
|
|
}
|