-
Notifications
You must be signed in to change notification settings - Fork 305
/
Copy pathprocessLogParse.js
43 lines (42 loc) · 1.31 KB
/
processLogParse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const insignificantDeaths = [
'npc_dota_creep',
'npc_dota_neutral',
];
function translate(s) {
return s === 'dota_unknown' ? null : s;
}
/**
* A processor to reduce the event stream to only logs we want to persist
* */
function processReduce(entries, meta) {
const result = entries.filter((e) => {
if (e.type === 'DOTA_COMBATLOG_PURCHASE'
|| (e.type === 'DOTA_COMBATLOG_DEATH' && insignificantDeaths.every(prefix => e.targetname.indexOf(prefix) !== 0))
) {
return Boolean(e.time);
}
return false;
}).map((e) => {
const e2 = Object.assign({}, e, {
match_id: meta.match_id,
attackername_slot: meta.slot_to_playerslot[meta.hero_to_slot[e.attackername]],
targetname_slot: meta.slot_to_playerslot[meta.hero_to_slot[e.targetname]],
sourcename_slot: meta.slot_to_playerslot[meta.hero_to_slot[e.sourcename]],
targetsourcename_slot: meta.slot_to_playerslot[meta.hero_to_slot[e.targetname]],
player1_slot: meta.slot_to_playerslot[e.player1],
player_slot: e.player_slot || meta.slot_to_playerslot[e.slot],
inflictor: translate(e.inflictor),
});
return e2;
});
/*
var count = {};
result.forEach(function(r)
{
count[r.type] = (count[r.type] || 0) + 1;
});
console.log(count);
*/
return result;
}
module.exports = processReduce;