Created
May 17, 2013 17:48
-
-
Save BenLubar/5600720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (doc, meta) { | |
if (doc.Type == 'killed') { | |
emit(dateToArray(doc.Time), {Attacker: doc.Attacker.Class, Victim: doc.Victim.Class, Weapon: doc.Weapon}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(key, values, rereduce) { | |
var result = {}; | |
if (rereduce) { | |
values.forEach(function(v) { | |
for (var attacker in v) { | |
result[attacker] = result[attacker] || {}; | |
for (var victim in v[attacker]) { | |
result[attacker][victim] = result[attacker][victim] || {}; | |
for (var weapon in v[attacker][victim]) { | |
result[attacker][victim][weapon] = result[attacker][victim][weapon] || 0; | |
result[attacker][victim][weapon] += v[attacker][victim][weapon]; | |
} | |
} | |
} | |
}); | |
} else { | |
values.forEach(function(v) { | |
result[v.Attacker] = result[v.Attacker] || {}; | |
result[v.Attacker][v.Victim] = result[v.Attacker][v.Victim] || {}; | |
result[v.Attacker][v.Victim][v.Weapon] = result[v.Attacker][v.Victim][v.Weapon] || 0; | |
++result[v.Attacker][v.Victim][v.Weapon]; | |
}); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment