holochain-open-dev / holoom

Tools for weaving blockchain data into holochain
Other
2 stars 1 forks source link

Author JQ query encoding described rules with the right tournament data etc #37

Closed dcatki closed 4 months ago

8e8b2c commented 4 months ago

This orders players by team wins then kills:

def pick_player_stats:
    . as $team |
    $team.players | map(
        {
            id: .player_id,
            kills: .player_stats.Kills | tonumber,
            team_wins: $team."team_stats"."Team Win" | tonumber
        }
    );

[.[].rounds] | 
add | 
[.[].teams] |
add |
map(pick_player_stats) |
add |
group_by(.id) |
map({
    id: .[0].id,
    kills: [.[].kills] | add,
    team_wins: [.[].team_wins] | add,
}) |
group_by(.team_wins) |
map(sort_by(.kills)) |
add |
reverse
8e8b2c commented 4 months ago

E.g. produces:

[
  {
    "id": "b5ddb9e6-00ff-4efa-ba12-363872f15039",
    "kills": 27,
    "team_wins": 2
  },
  {
    "id": "6f6f1035-4085-414a-805d-258036fbb252",
    "kills": 25,
    "team_wins": 2
  },
  {
    "id": "0e67e40f-3477-4e77-8820-93c5f71b20d5",
    "kills": 19,
    "team_wins": 2
  },
  {
    "id": "a1a428f0-54b2-4171-a8d2-b84f50daef6c",
    "kills": 14,
    "team_wins": 2
  },
  {
    "id": "f83dde07-bb36-4e84-bc50-160f90d2676e",
    "kills": 25,
    "team_wins": 1
  },
  {
    "id": "9ccc1bdb-60bf-483e-9aac-c6cd000bb2a7",
    "kills": 12,
    "team_wins": 1
  },
  {
    "id": "c2ba3fbe-709d-4148-9e2d-b187e0981d09",
    "kills": 10,
    "team_wins": 1
  },
  {
    "id": "a37eb0e6-1fb9-4b3f-9a1f-2075748ccf14",
    "kills": 9,
    "team_wins": 1
  },
  {
    "id": "c198c0ef-207a-4cca-b243-2d96d0db5ae1",
    "kills": 12,
    "team_wins": 0
  },
  {
    "id": "aa828c1e-44d4-410c-8fb1-3aa415e6c0e0",
    "kills": 7,
    "team_wins": 0
  },
  {
    "id": "1d5abd62-9b83-44b5-af87-03976524bcb2",
    "kills": 6,
    "team_wins": 0
  },
  {
    "id": "d79a160d-bdba-4f08-907b-1e636e5219a9",
    "kills": 4,
    "team_wins": 0
  },
  {
    "id": "7d9f7b17-c345-4865-8429-cd7e73aa5e43",
    "kills": 4,
    "team_wins": 0
  },
  {
    "id": "863c4d39-02b1-4c85-abe7-6843534bdefc",
    "kills": 1,
    "team_wins": 0
  }
]