<commit_before>(function() {
	'use strict';
	pinpointApp.constant( "StatisticCtrlConfig", {
		ID: "STAT_CTRL_",
		PAGE_NAME: "statistic",
		SLASH: "/"
	});
	pinpointApp.controller("StatisticCtrl", [ "StatisticCtrlConfig", "$scope", "$routeParams", "locationService", "$http", "CommonUtilService", "AgentDaoService", "UrlVoService",
		function ( cfg, $scope, $routeParams, locationService, $http, CommonUtilService, AgentDaoService, UrlVoService) {
			cfg.ID +=  CommonUtilService.getRandomNum();
			// AnalyticsService.send(AnalyticsService.CONST.INSPECTOR_PAGE);

			$scope.$on( "up.changed.application", function ( event, invokerId, newAppName ) {
				UrlVoService.setApplication( newAppName );
				changeLocation(function() {
					$scope.$broadcast( "down.changed.application", invokerId );
					loadStatChart();
				});
			});
			$scope.$on( "up.changed.period", function ( event, invokerId ) {
				changeLocation(function() {
					$scope.$broadcast( "down.changed.period", true, invokerId );
					loadStatChart();
				});

			});

			function loadStatChart() {
				var oParam = {
					to : UrlVoService.getQueryEndTime(),
					from : UrlVoService.getQueryStartTime(),
					sampleRate: 1,
					applicationId: UrlVoService.getApplicationName()
				};
				if ( oParam.from > 0 && oParam.to > 0 ) {
					$http.get( "getApplicationStat/cpuLoad/chart.pinpoint" +  getQueryStr(oParam) ).then(function(chartData) {
						if ( angular.isUndefined(chartData.data.exception) ) {
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.jvm", makeChartData({
								id: "jvmCpuLoad",
								title: "JVM Cpu Usage",
								isAvailable: false,
								maximum: true
							}, "Cpu Usage (%)", ["JVM(avg)", "JVM(max)", "JVM(min)"], chartData.data.charts["CPU_LOAD_JVM"]), "100%", "270px");
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.system", makeChartData({
								id: "systemCpuLoad",
								title: "System Cpu Usage",
								isAvailable: false,
								maximum: true
							}, "Cpu Usage (%)", ["System(avg)", "System(max)", "System(min)"], chartData.data.charts["CPU_LOAD_SYSTEM"]), "100%", "270px");
						} else {
							console.log("error");
						}
					}, function(error) {
					});
					$http.get( "getApplicationStat/memory/chart.pinpoint" +  getQueryStr(oParam) ).then(function(chartData) {
						if ( angular.isUndefined(chartData.data.exception) ) {
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.heap", makeChartData({
								id: "memoryHeapLoad",
								title: "Memory Heap",
								isAvailable: false,
								maximum: false
							}, "Memory(bytes)", ["JVM(avg)", "JVM(max)", "JVM(min)"], chartData.data.charts["MEMORY_HEAP"]), "100%", "270px");
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.non-heap", makeChartData({
								id: "memoryNonHeapLoad",
								title: "Memory Non Heap",
								isAvailable: false,
								maximum: false
							}, "Memory(bytes)", ["System(avg)", "System(max)", "System(min)"], chartData.data.charts["MEMORY_NON_HEAP"]), "100%", "270px");
						} else {
							console.log("error");
						}
					}, function(error) {
					});
				}
			}
			function makeChartData(chartProperty, chartTitle, legendTitles, chartData) {
				var returnData = {
					data: [],
					title: legendTitles,
					field: ["avg", "max", "min", "maxAgent", "minAgent"],
					chartTitle: chartTitle,
					maximum: chartProperty.maximum
				};
				if (chartData) {
					chartProperty.isAvailable = true;
				} else {
					return returnData;
				}
				var pointsData = chartData.points;
				var length = pointsData.length;
				for (var i = 0; i < length; ++i) {
					returnData.data.push({
						"time": moment(pointsData[i]['xVal']).format("YYYY-MM-DD HH:mm:ss"),
						"avg": pointsData[i]['yValForAvg'].toFixed(2),
						"min": pointsData[i]['yValForMin'].toFixed(2),
						"max": pointsData[i]['yValForMax'].toFixed(2),
						"minAgent": pointsData[i]['agentIdForMin'],
						"maxAgent": pointsData[i]['agentIdForMax']
					});
				}
				return returnData;
			}
			function changeLocation( callback ) {
				var newPath = getLocation();
				if ( locationService.path() !== newPath ) {
					locationService.skipReload().path( newPath ).replace();
					if (!$scope.$$phase) {
						$scope.$apply();
					}
					callback();
				}
			}
			function getLocation() {
				var url = [<commit_msg>[#2970] remove y-axis field when value is -1.<commit_after>(function() {
	'use strict';
	pinpointApp.constant( "StatisticCtrlConfig", {
		ID: "STAT_CTRL_",
		PAGE_NAME: "statistic",
		SLASH: "/"
	});
	pinpointApp.controller("StatisticCtrl", [ "StatisticCtrlConfig", "$scope", "$routeParams", "locationService", "$http", "CommonUtilService", "AgentDaoService", "UrlVoService",
		function ( cfg, $scope, $routeParams, locationService, $http, CommonUtilService, AgentDaoService, UrlVoService) {
			cfg.ID +=  CommonUtilService.getRandomNum();
			// AnalyticsService.send(AnalyticsService.CONST.INSPECTOR_PAGE);

			$scope.$on( "up.changed.application", function ( event, invokerId, newAppName ) {
				UrlVoService.setApplication( newAppName );
				changeLocation(function() {
					$scope.$broadcast( "down.changed.application", invokerId );
					loadStatChart();
				});
			});
			$scope.$on( "up.changed.period", function ( event, invokerId ) {
				changeLocation(function() {
					$scope.$broadcast( "down.changed.period", true, invokerId );
					loadStatChart();
				});

			});

			function loadStatChart() {
				var oParam = {
					to : UrlVoService.getQueryEndTime(),
					from : UrlVoService.getQueryStartTime(),
					sampleRate: 1,
					applicationId: UrlVoService.getApplicationName()
				};
				if ( oParam.from > 0 && oParam.to > 0 ) {
					$http.get( "getApplicationStat/cpuLoad/chart.pinpoint" +  getQueryStr(oParam) ).then(function(chartData) {
						if ( angular.isUndefined(chartData.data.exception) ) {
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.jvm", makeChartData({
								id: "jvmCpuLoad",
								title: "JVM Cpu Usage",
								isAvailable: false,
								maximum: true
							}, "Cpu Usage (%)", ["JVM(avg)", "JVM(max)", "JVM(min)"], chartData.data.charts["CPU_LOAD_JVM"]), "100%", "270px");
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.system", makeChartData({
								id: "systemCpuLoad",
								title: "System Cpu Usage",
								isAvailable: false,
								maximum: true
							}, "Cpu Usage (%)", ["System(avg)", "System(max)", "System(min)"], chartData.data.charts["CPU_LOAD_SYSTEM"]), "100%", "270px");
						} else {
							console.log("error");
						}
					}, function(error) {
					});
					$http.get( "getApplicationStat/memory/chart.pinpoint" +  getQueryStr(oParam) ).then(function(chartData) {
						if ( angular.isUndefined(chartData.data.exception) ) {
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.heap", makeChartData({
								id: "memoryHeapLoad",
								title: "Memory Heap",
								isAvailable: false,
								maximum: false
							}, "Memory(bytes)", ["JVM(avg)", "JVM(max)", "JVM(min)"], chartData.data.charts["MEMORY_HEAP"]), "100%", "270px");
							$scope.$broadcast("statisticChartDirective.initAndRenderWithData.non-heap", makeChartData({
								id: "memoryNonHeapLoad",
								title: "Memory Non Heap",
								isAvailable: false,
								maximum: false
							}, "Memory(bytes)", ["System(avg)", "System(max)", "System(min)"], chartData.data.charts["MEMORY_NON_HEAP"]), "100%", "270px");
						} else {
							console.log("error");
						}
					}, function(error) {
					});
				}
			}
			function makeChartData(chartProperty, chartTitle, legendTitles, chartData) {
				var returnData = {
					data: [],
					title: legendTitles,
					field: ["avg", "max", "min", "maxAgent", "minAgent"],
					chartTitle: chartTitle,
					maximum: chartProperty.maximum
				};
				if (chartData) {
					chartProperty.isAvailable = true;
				} else {
					return returnData;
				}
				var pointsData = chartData.points;
				var length = pointsData.length;
				for (var i = 0; i < length; ++i) {
					if ( pointsData[i]['yValForAvg'] === -1 || pointsData[i]['yValForMin'] === -1 || pointsData[i]['yValForMax'] === -1 ) {
						returnData.data.push({
							"time": moment(pointsData[i]['xVal']).format("YYYY-MM-DD HH:mm:ss")
						});
					} else {
						returnData.data.push({
							"time": moment(pointsData[i]['xVal']).format("YYYY-MM-DD HH:mm:ss"),
							"avg": pointsData[i]['yValForAvg'].toFixed(2),
							"min": pointsData[i]['yValForMin'].toFixed(2),
							"max": pointsData[i]['yValForMax'].toFixed(2),
							"minAgent": pointsData[i]['agentIdForMin'],
							"maxAgent": pointsData[i]['agentIdForMax']
						});
					}
				}
				return returnData;
			}
			function changeLocation( callback ) {
				var newPath = getLocation();
				if ( locationService.path() !== newPath ) {
					locationService.skipReload().path( newPath ).replace();
					if (!$scope.$$phase) {
						$scope.$apply();
					}
					callback();
				}
			}
			function getLocation() {
				var url = [
{'fraction_non_alphanumeric': 0.17150076906174466, 'fraction_numerical': 0.007690617446715007, 'mean_word_length': 3.429683698296837, 'pattern_counts': {'":': 13, '<': 5, '<?xml version=': 0, '>': 7, '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': '6718454', 'n_tokens_mistral': 3920, 'n_tokens_neox': 2920, 'n_words': 505}