updown = {
let updown = [];
let state = {};
let ts = null;
data.initial_state.filter( d => asfam_filter( d[5] ) ).forEach( d => {
state[ [ d[3],d[5] ] ] = d3.timeParse("%s")( d[1] )
});
updates.forEach( x => {
if( x.type == 'W' && [ x.peer_ip, x.pfx ] in state) {
updown.push({
'peer_ip': x.peer_ip,
'pfx': x.pfx,
'start_ts': state[ [x.peer_ip, x.pfx] ],
'end_ts': x.ts
});
delete state[ [ x.peer_ip, x.pfx ] ];
} else if ( x.type == 'A' && state[ x.peer_ip, x.pfx ] === undefined ) {
state[ [ x.peer_ip, x.pfx ] ] = x.ts
} else {
}
});
for ( var key in state ) {
key = key.split(',');
updown.push({
'peer_ip': key[0],
'pfx': key[1],
'start_ts': state[ key ],
'end_ts': d3.timeParse("%s")( data.meta.last_ts ),
'box_end': true
});
}
return updown
};