I am working with the github API to retrieve an array of objects containing commit data. My goal is to extract a unique list of commitors and format it as shown below to create a graph:
{"id":temp,"label":temp,"type": "number","p": {} }
Here is the code I have written so far:
$scope.git = response.data;
$scope.o=[];
angular.forEach($scope.git,function(value){
var temp = value.commit.author.name;
if($scope.o.length==0){
$scope.o.push({"id":temp,"label":temp,"type": "number",
"p": {}
})
}
else{
angular.forEach($scope.o,function(ob){
if(ob.id==temp){
continue;
}
else{
$scope.o.push({"id":temp,"label":temp,"type": "number",
"p": {}
})
}
});
}
})
Although this code works, it is not very efficient. Is there a more efficient way to achieve the same result?