moth/bin/points

47 lines
612 B
Plaintext
Raw Normal View History

2015-04-08 17:28:18 -06:00
#! /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)
2015-04-08 17:28:18 -06:00
}
if (NR > 1) {
# JSON sucks.
print ",";
}
printf("[%d, \"%s\", \"%s\", %d]", ts, hash, cat, points);
2015-04-08 17:28:18 -06:00
}
END {
print "";
print " ],";
print " \"teams\": {";
i = 0
for (hash in teamnames) {
if (i++) {
print ",";
}
printf("\"%s\": \"%s\"", hash, teamnames[hash]);
2015-04-08 17:28:18 -06:00
}
print "";
print " }";
print "}";
2015-04-22 08:31:00 -06:00
}