mirror of https://github.com/dirtbags/moth.git
47 lines
612 B
Awk
Executable File
47 lines
612 B
Awk
Executable File
#! /usr/bin/awk -f
|
|
|
|
BEGIN {
|
|
nteams = 0;
|
|
print "{";
|
|
print " \"points\": [";
|
|
}
|
|
|
|
{
|
|
ts = $1;
|
|
hash = $2;
|
|
cat = $3;
|
|
points = $4;
|
|
|
|
teamno = teams[hash];
|
|
if (! teamno) {
|
|
teamno = ++nteams;
|
|
teams[hash] = teamno;
|
|
|
|
getline teamnames[hash] < ("state/teams/" hash)
|
|
}
|
|
|
|
if (NR > 1) {
|
|
# JSON sucks.
|
|
print ",";
|
|
}
|
|
printf("[%d, \"%s\", \"%s\", %d]", ts, hash, cat, points);
|
|
}
|
|
|
|
END {
|
|
print "";
|
|
print " ],";
|
|
print " \"teams\": {";
|
|
|
|
i = 0
|
|
for (hash in teamnames) {
|
|
if (i++) {
|
|
print ",";
|
|
}
|
|
printf("\"%s\": \"%s\"", hash, teamnames[hash]);
|
|
}
|
|
|
|
print "";
|
|
print " }";
|
|
print "}";
|
|
}
|