remove dumps and trash
add some new files and services add hwtools that shows the current and last GWs - not yet included the user stats (if any available)
This commit is contained in:
45
server/services/datacollector/arenaAttack.go
Normal file
45
server/services/datacollector/arenaAttack.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package datacollector
|
||||
|
||||
import (
|
||||
"hwcollector/server/models"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func init() {
|
||||
processes["arenaAttack"] = new(DoArenaAttack)
|
||||
}
|
||||
|
||||
// DoArenaAttack ...
|
||||
type DoArenaAttack struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
// Start ...
|
||||
func (x *DoArenaAttack) Start() {
|
||||
}
|
||||
|
||||
// SetJSONByte ...
|
||||
func (x *DoArenaAttack) SetJSONByte(b []byte) {
|
||||
x.data = b
|
||||
}
|
||||
|
||||
// SetJSON ...
|
||||
func (x *DoArenaAttack) SetJSON(s string) {
|
||||
x.data = []byte(s)
|
||||
}
|
||||
|
||||
// GetUserDetails ...
|
||||
func (x *DoArenaAttack) 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
|
||||
}
|
||||
Reference in New Issue
Block a user