<commit_before>(function (angular) {
    "use strict";
    angular.module('dashboard.analytics')
        .controller('capacityReportCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout','$location', '$anchorScroll','$modal',function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout,$location, $anchorScroll,$modal){
            $rootScope.stateItems = $state.params;
            //analyticsServices.initFilter();
            $scope.gototab = function(id) {
                // set the location.hash to the id of
                // the element you wish to scroll to.
                $location.hash(id);

                // call $anchorScroll()
                $anchorScroll();
            };
            var capRept =this;
            capRept.chartData=[];
            capRept.splitUp=null;
            capRept.getCapacityData=function(fltObj){
                var param = {
                    // url: 'src/partials/sections/dashboard/analytics/data/cost.json?org'
                    url:''
                };
                if(fltObj && fltObj.org){
                    var entityId=null;
                    if(fltObj.provider){
                        entityId=fltObj.provider.id;
                    } else {
                        entityId=fltObj.org.id;
                    }
                    //param.url='http://d4d.rlcatalyst.com/analytics/capacity?parentEntityId=46d1da9a-d927-41dc-8e9e-7e926d927537&entityId=46d1da9a-d927-41dc-8e9e-7e926d927537&toTimeStamp=Mon%20Nov%2014%202016%2010:41:29%20GMT+0530%20(IST)&period=month';
                   param.url='/analytics/capacity?parentEntityId='+fltObj.org.id+'&entityId='+entityId+'&toTimeStamp='+new Date()+'&period=month';
                }

                genSevs.promiseGet(param).then(function (result) {
                    capRept.chartData=result;
                    $rootScope.splitUpCapacities=[];
                    capRept.serviceCapacity=result.capacity.AWS;
                    capRept.serviceType=Object.keys(capRept.serviceCapacity.services)[0];
                    if(result.splitUpCapacities && Object.keys(result.splitUpCapacities).length >0) {
                        angular.forEach(result.splitUpCapacities, function (val, key) {
                            var a=key.replace(/([A-Z])/g, ' $1').replace(/^./, function(str) {
                                return str.toUpperCase();
                            });
                            $rootScope.splitUpCapacities.push({id:key,val:a});
                        });
                        if( $rootScope.splitUpCapacities && $rootScope.splitUpCapacities.length >0) {
                            $scope.$emit('CHANGE_splitUp', $rootScope.splitUpCapacities[0].id);
                            capRept.splitUp = $rootScope.splitUpCapacities[0].val;
                            capRept.createLable(result, $rootScope.splitUpCapacities[0].id);
                        }
                    }
                    capRept.createList();

                });
            };

            $rootScope.applyFilter =function(filterApp,period){
                analyticsServices.applyFilter(filterApp,period);
                if($state.current.name === "dashboard.analytics.capacityReport") {
                    capRept.createList();
                }
            };
            capRept.init =function(){
                $rootScope.organNewEnt.instanceType='Unassigned';
                $rootScope.organNewEnt.provider='0';
                $rootScope.$emit('INI_usage', 'Unassigned');
                $timeout(function () {
                    $rootScope.applyFilter(true,'month');
                    capRept.getCapacityData($rootScope.filterNewEnt);
                    var treeNames = ['Cloud Management','Analytics','capacity'];
                    $rootScope.$emit('treeNameUpdate', treeNames);
                },500);
            };
            // new e###################################
            $scope.openChart=function (id) {
                $modal.open({
                    animation: true,
                    templateUrl: 'src/partials/sections/dashboard/analytics/view/capacityChart.html',
                    controller: 'capacityChartCtrl as capChat',
                    backdrop : 'static',
                    keyboard: false,
                    resolve: {
                        items: function() {
                            return id;
                        }
                    }
                }).
                result.then(function() {

                }, function() {

                });
            };
            $scope.chefConfig=function (id) {
                var promise = genSevs.editRunlist(id);
            };
            capRept.createList = function () {
                capRept.filterValue='';
                capRept.listGrid=[];
                var fltrObj=$rootScope.filterNewEnt;

               // for(var value in capRept.serviceCapacity) {
                var value=capRept.serviceType;
                    capRept.listGrid[value]=[];
                    capRept.listGrid[value].data=[];
                    capRept.listGrid[value].paginationPageSizes= [25, 50, 100];
                    capRept.listGrid[value].paginationPageSize=25;
                    $scope.colArray=['platformId','state','orgName','privateIpAddress','os']
                if(capRept.serviceType !== 'S3') {
                    capRept.listGrid[value].columnDefs = [
                        {name: 'Instance Id', field: 'platformId', cellTooltip: true},
                        {name: 'os', enableFiltering: true, displayName: 'OS', field: 'os', cellTooltip: true},
                        {name: 'privateIpAddress', displayName: 'IP Address', cellTooltip: true},
                        {name: 'state', displayName: 'Status', cellTooltip: true},
                        {
                            name: 'Region', displayName: 'Region',
                            field: 'providerData.region',
                            cellTooltip: true
                        },
                        {name: 'orgName', displayName: 'Org Name', field: 'orgName', cellTooltip: true},
                        {
                            name: 'cost',
                            displayName: 'Cost',
                            cellTemplate: '<span ng-bind-html="grid.appScope.aggregateInstanceCost(row.entity.cost)"></span>'
                        },
                        {
                            name: 'Action',
                            cellTooltip: true,
                            cellTemplate: "<span class='cursor' title='Usage' style='font-size: 14px;' ng-click='grid.appScope.openChart(row.entity)'><i class=\"fa fa-line-chart\"></i></span> " +
                            "&nbsp;&nbsp; <span ng-show='row.entity.showSchedule' class='cursor' ng-click='grid.appScope.Schedule(row.entity._id)' style='font-size: 14px;' title='Schedule'><i class=\"fa fa-calendar\"></i></span>"
                        }
                        // {name: 'Chef', cellTooltip: true,cellTemplate:"<span class='cursor' ng-click='grid.appScope.chefConfig(row.entity)'><i  class=\"fa fa-eye\" title=\"Chef Configuration\"></i></span>"}
                    ];
                }
                if(capRept.serviceType === 'S3'){
                    $scope.colArray=['bucketName','bucketOwnerName','orgName']
                    capRept.listGrid[value].columnDefs=[
                        {name: 'bucketName', field: 'bucketName', cellTooltip: true},
                        {name: 'bucketOwnerName', field: 'bucketOwnerName', cellTooltip: true},
                        {name: 'bucketSize', field: 'bucketSize', displayName:'Bucket Size (MB)', cellTooltip: true},
                        {name: 'orgName', field: 'orgName', cellTooltip: true},
                        {name: 'cost', displayName: 'Cost',cellTemplate: '<span ng-bind-html="grid.appScope.aggregateInstanceCost(row.entity.cost)"></span>'},
                        {name: 'Action', cellTooltip: true,cellTemplate:"<span class='cursor' title='Usage' style='font-size: 14px;' ng-click='grid.appScope.openChart(row.entity)'><i class=\"fa fa-line-chart\"></i></span> "}
                    ]
                }
                    capRept.listGrid[value].onRegisterApi=function (gridApi) {
                       gridApi.grid.registerRowsProcessor($scope.singleFilter, 200);<commit_msg>used a foreach for creating object in instance list<commit_after>(function (angular) {
    "use strict";
    angular.module('dashboard.analytics')
        .controller('capacityReportCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout','$location', '$anchorScroll','$modal',function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout,$location, $anchorScroll,$modal){
            $rootScope.stateItems = $state.params;
            //analyticsServices.initFilter();
            $scope.gototab = function(id) {
                // set the location.hash to the id of
                // the element you wish to scroll to.
                $location.hash(id);

                // call $anchorScroll()
                $anchorScroll();
            };
            var capRept =this;
            capRept.chartData=[];
            capRept.splitUp=null;
            capRept.getCapacityData=function(fltObj){
                var param = {
                    // url: 'src/partials/sections/dashboard/analytics/data/cost.json?org'
                    url:''
                };
                if(fltObj && fltObj.org){
                    var entityId=null;
                    if(fltObj.provider){
                        entityId=fltObj.provider.id;
                    } else {
                        entityId=fltObj.org.id;
                    }
                    //param.url='http://d4d.rlcatalyst.com/analytics/capacity?parentEntityId=46d1da9a-d927-41dc-8e9e-7e926d927537&entityId=46d1da9a-d927-41dc-8e9e-7e926d927537&toTimeStamp=Mon%20Nov%2014%202016%2010:41:29%20GMT+0530%20(IST)&period=month';
                   param.url='/analytics/capacity?parentEntityId='+fltObj.org.id+'&entityId='+entityId+'&toTimeStamp='+new Date()+'&period=month';
                }

                genSevs.promiseGet(param).then(function (result) {
                    capRept.chartData=result;
                    $rootScope.splitUpCapacities=[];
                    capRept.serviceCapacity=result.capacity.AWS;
                    capRept.serviceType=Object.keys(capRept.serviceCapacity.services)[0];
                    if(result.splitUpCapacities && Object.keys(result.splitUpCapacities).length >0) {
                        angular.forEach(result.splitUpCapacities, function (val, key) {
                            var a=key.replace(/([A-Z])/g, ' $1').replace(/^./, function(str) {
                                return str.toUpperCase();
                            });
                            $rootScope.splitUpCapacities.push({id:key,val:a});
                        });
                        if( $rootScope.splitUpCapacities && $rootScope.splitUpCapacities.length >0) {
                            $scope.$emit('CHANGE_splitUp', $rootScope.splitUpCapacities[0].id);
                            capRept.splitUp = $rootScope.splitUpCapacities[0].val;
                            capRept.createLable(result, $rootScope.splitUpCapacities[0].id);
                        }
                    }
                    capRept.createList();

                });
            };

            $rootScope.applyFilter =function(filterApp,period){
                analyticsServices.applyFilter(filterApp,period);
                if($state.current.name === "dashboard.analytics.capacityReport") {
                    capRept.createList();
                }
            };
            capRept.init =function(){
                $rootScope.organNewEnt.instanceType='Unassigned';
                $rootScope.organNewEnt.provider='0';
                $rootScope.$emit('INI_usage', 'Unassigned');
                $timeout(function () {
                    $rootScope.applyFilter(true,'month');
                    capRept.getCapacityData($rootScope.filterNewEnt);
                    var treeNames = ['Cloud Management','Analytics','capacity'];
                    $rootScope.$emit('treeNameUpdate', treeNames);
                },500);
            };
            // new e###################################
            $scope.openChart=function (id) {
                $modal.open({
                    animation: true,
                    templateUrl: 'src/partials/sections/dashboard/analytics/view/capacityChart.html',
                    controller: 'capacityChartCtrl as capChat',
                    backdrop : 'static',
                    keyboard: false,
                    resolve: {
                        items: function() {
                            return id;
                        }
                    }
                }).
                result.then(function() {

                }, function() {

                });
            };
            $scope.chefConfig=function (id) {
                var promise = genSevs.editRunlist(id);
            };
            capRept.createList = function () {
                capRept.filterValue='';
                capRept.listGrid=[];
                var fltrObj=$rootScope.filterNewEnt;

               // for(var value in capRept.serviceCapacity) {
                var value=capRept.serviceType;
                    capRept.listGrid[value]=[];
                    capRept.listGrid[value].data=[];
                    capRept.listGrid[value].paginationPageSizes= [25, 50, 100];
                    capRept.listGrid[value].paginationPageSize=25;
                    $scope.colArray=['platformId','state','orgName','privateIpAddress','os']
                if(capRept.serviceType !== 'S3') {
                    capRept.listGrid[value].columnDefs = [
                        {name: 'Instance Id', field: 'platformId', cellTooltip: true},
                        {name: 'os', enableFiltering: true, displayName: 'OS', field: 'os', cellTooltip: true},
                        {name: 'privateIpAddress', displayName: 'IP Address', cellTooltip: true},
                        {name: 'state', displayName: 'Status', cellTooltip: true},
                        {
                            name: 'Region', displayName: 'Region',
                            field: 'region',
                            cellTooltip: true
                        },
                        {name: 'orgName', displayName: 'Org Name', field: 'orgName', cellTooltip: true},
                        {
                            name: 'cost',
                            displayName: 'Cost',
                            cellTemplate: '<span ng-bind-html="grid.appScope.aggregateInstanceCost(row.entity.cost)"></span>'
                        },
                        {
                            name: 'Action',
                            cellTooltip: true,
                            cellTemplate: "<span class='cursor' title='Usage' style='font-size: 14px;' ng-click='grid.appScope.openChart(row.entity)'><i class=\"fa fa-line-chart\"></i></span> " +
                            "&nbsp;&nbsp; <span ng-show='row.entity.showSchedule' class='cursor' ng-click='grid.appScope.Schedule(row.entity._id)' style='font-size: 14px;' title='Schedule'><i class=\"fa fa-calendar\"></i></span>"
                        }
                        // {name: 'Chef', cellTooltip: true,cellTemplate:"<span class='cursor' ng-click='grid.appScope.chefConfig(row.entity)'><i  class=\"fa fa-eye\" title=\"Chef Configuration\"></i></span>"}
                    ];
                }
                if(capRept.serviceType === 'S3'){
                    $scope.colArray=['bucketName','bucketOwnerName','orgName']
                    capRept.listGrid[value].columnDefs=[
                        {name: 'bucketName', field: 'bucketName', cellTooltip: true},
                        {name: 'bucketOwnerName', field: 'bucketOwnerName', cellTooltip: true},
                        {name: 'bucketSize', field: 'bucketSize', displayName:'Bucket Size (MB)', cellTooltip: true},
                        {name: 'orgName', field: 'orgName', cellTooltip: true},
                        {name: 'cost', displayName: 'Cost',cellTemplate: '<span ng-bind-html="grid.appScope.aggregateInstanceCost(row.entity.cost)"></span>'},
                        {name: 'Action', cellTooltip: true,cellTemplate:"<span class='cursor' title='Usage' style='font-size: 14px;' ng-click='grid.appScope.openChart(row.entity)'><i class=\"fa fa-line-chart\"></i></span> "}
                    ]
                }
                    capRept.listGrid[value].onRegisterApi=function (gridApi) {
                       gridApi.grid.registerRowsProcessor($scope.singleFilter, 200);
{'fraction_non_alphanumeric': 0.13636632550434835, 'fraction_numerical': 0.012068863515352305, 'mean_word_length': 1.5473176612417119, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110997', 'n_tokens_mistral': 4612, 'n_tokens_neox': 4339, 'n_words': 611}