So I have this JavaScript literal that is displaying a tree structure using arborjs.
var data = {
"nodes": {
You: {
'color': 'green',
'shape': 'dot',
'label': 'You'
},
Ben: {
'color': 'black',
'shape': 'dot',
'label': 'Ben'
},
David: {
'color': 'black',
'shape': 'dot',
'label': 'David'
}
},
"edges": {
You: {
Ben: {},
David: {}
},
Ben: {
David: {}
}
}
};
I want to count the number of properties in the nodes object (3 in this case) and number of properties in the edges object (2 in this case) to display some statistics for the user tree. I output the data variable using ruby on rails by recursively going over my database and creating a hash. But before, should I count the nodes client side or server side? Should I go over the database again and count statistics or just count the properties?