<commit_before>(function(angular) {
	'use strict';
	
	var app = angular.module('bugminerApp', ['ngResource', 'ngRoute', 'ui.bootstrap']);
	
	app.config(['$routeProvider', function($routeProvider) {
		$routeProvider
			.when('/', {
				templateUrl: 'partials/projects/index.html',
				controller: 'ProjectsCtrl'
			})
			.when('/projects/:name/:tab?', {
				templateUrl: 'partials/projects/view.html',
				controller: 'ProjectCtrl',
				reloadOnSearch: false
			});
	}]);
	
	app.factory('Project', function($resource) {
		  return $resource('/api/projects/:name');
	});
	
	app.factory('BugPage', function($resource, $routeParams) {
		  return $resource('/api/projects/:name/bugs', {name: $routeParams.name, sort: 'reportTime', size: 10});
	});

	app.factory('LineChange', function($resource, $routeParams) {
		return $resource('/api/projects/:name/bugs/:tracker/:key/diff', {name: $routeParams.name});
	});
	
	app.controller('ProjectsCtrl', function($scope, Project) {
		Project.query(function(data) {
			$scope.projects = data;
			console.log(data);
		});
	});

	app.controller('ProjectCtrl', function($scope, $routeParams, $location) {
		$scope.tab = $routeParams.tab;

		// set dashboard to default
		if ($scope.tab == null) {
			$scope.tab = 'dashboard';
		}

		$scope.navigateTo = function(tab) {
			$location.path('/projects/' + $routeParams.name + '/' + tab);
			$location.search({});
		};
	});
	
	app.controller('ProjectBugsCtrl', function($scope, $routeParams, $location, BugPage, LineChange) {
		$scope.currentPage = $routeParams.page ? $routeParams.page : 1;
		$scope.currentBug = null;
		$scope.changedFiles = [];


		$scope.$watch('currentPage', function() {
			$location.search({page: $scope.currentPage});

			// reset when navigating, as bug will not be in the list anymore
			$scope.currentBug = null;

			BugPage.get({page: $scope.currentPage - 1}, function(data) {
				$scope.bugs = data.content;
				$scope.totalItems = data.totalElements;
				$scope.itemsPerPage = data.size;
			});
		});

		$scope.setCurrentBug = function(bug) {
			$scope.currentBug = bug;

			// fetch line changes
			LineChange.query({tracker: bug.issueTracker.name, key: bug.key}, function(data) {
				var changedFiles = [];
				var lineChanges = data;
				var currentFileName = '';
				var currentFile = null;
				var currentEdit = {
					additions: [],
					deletions: [],
					lastLineNumber: 0
				};

				for (var i = 0; i < lineChanges.length; i++) {
					if (currentFileName !== lineChanges[i].fileName) {
						currentFileName = lineChanges[i].fileName;
<commit_msg>Fix: reset scopes changed files not local var<commit_after>(function(angular) {
	'use strict';
	
	var app = angular.module('bugminerApp', ['ngResource', 'ngRoute', 'ui.bootstrap']);
	
	app.config(['$routeProvider', function($routeProvider) {
		$routeProvider
			.when('/', {
				templateUrl: 'partials/projects/index.html',
				controller: 'ProjectsCtrl'
			})
			.when('/projects/:name/:tab?', {
				templateUrl: 'partials/projects/view.html',
				controller: 'ProjectCtrl',
				reloadOnSearch: false
			});
	}]);
	
	app.factory('Project', function($resource) {
		  return $resource('/api/projects/:name');
	});
	
	app.factory('BugPage', function($resource, $routeParams) {
		  return $resource('/api/projects/:name/bugs', {name: $routeParams.name, sort: 'reportTime', size: 10});
	});

	app.factory('LineChange', function($resource, $routeParams) {
		return $resource('/api/projects/:name/bugs/:tracker/:key/diff', {name: $routeParams.name});
	});
	
	app.controller('ProjectsCtrl', function($scope, Project) {
		Project.query(function(data) {
			$scope.projects = data;
			console.log(data);
		});
	});

	app.controller('ProjectCtrl', function($scope, $routeParams, $location) {
		$scope.tab = $routeParams.tab;

		// set dashboard to default
		if ($scope.tab == null) {
			$scope.tab = 'dashboard';
		}

		$scope.navigateTo = function(tab) {
			$location.path('/projects/' + $routeParams.name + '/' + tab);
			$location.search({});
		};
	});
	
	app.controller('ProjectBugsCtrl', function($scope, $routeParams, $location, BugPage, LineChange) {
		$scope.currentPage = $routeParams.page ? $routeParams.page : 1;
		$scope.currentBug = null;
		$scope.changedFiles = [];


		$scope.$watch('currentPage', function() {
			$location.search({page: $scope.currentPage});

			// reset when navigating, as bug will not be in the list anymore
			$scope.currentBug = null;

			BugPage.get({page: $scope.currentPage - 1}, function(data) {
				$scope.bugs = data.content;
				$scope.totalItems = data.totalElements;
				$scope.itemsPerPage = data.size;
			});
		});

		$scope.setCurrentBug = function(bug) {
			$scope.currentBug = bug;

			// fetch line changes
			LineChange.query({tracker: bug.issueTracker.name, key: bug.key}, function(data) {
				$scope.changedFiles = [];
				var lineChanges = data;
				var currentFileName = '';
				var currentFile = null;
				var currentEdit = {
					additions: [],
					deletions: [],
					lastLineNumber: 0
				};

				for (var i = 0; i < lineChanges.length; i++) {
					if (currentFileName !== lineChanges[i].fileName) {
						currentFileName = lineChanges[i].fileName;

{'fraction_non_alphanumeric': 0.1766982775304819, 'fraction_numerical': 0.002322430810915425, 'mean_word_length': 3.866290018832392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '926605', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1639, 'n_words': 316}