<commit_before>angular.module('ela', []).

controller('search', ['$scope', '$http', function ($scope, $http) {

	// Initialize user data
	$scope.users = $scope.filtered_users = [];
	$http.get('search.php').then(function (res) {
		$scope.users = res.data;

		var imgQueue = [];
		angular.forEach($scope.users, function (value) {
			value.Bio = value.First + /*' ' + value.Last +*/ ' ' + value.Bio;
			imgQueue.push(value);
		});

		// Image queue Processor
		(function ( queue ) {
			var image = new Image(), user;
			var queue_handler = function () {
				if (queue.length) {
					user = queue.shift();
					image.src = 'img/' + user.Last + ', ' + user.First + '.jpg';
				}
			};
			image.onload = queue_handler;
			image.onerror = function (e) {
				console.log('Image Frefetch Error');
				console.log(e);
				queue_handler();
			};
			queue_handler();
		})( imgQueue );
		
	});

	// Searching
	$scope.total_rows = function () {
		var tail = ($scope.filtered_users.length == $scope.users.length) ? '' : (' of ' + $scope.users.length);
		return 'Total: ' + $scope.filtered_users.length + tail;
	};

	// Pagination
	$scope.limits = [5,10,25,50,100];
	$scope.limit = $scope.limits[0];
	$scope.page = 1;
	$scope.pages = function () {
		return Math.ceil( $scope.filtered_users.length / $scope.limit ) || 1;
	};

	// Order By
	$scope.fields = [
		{field: ['First','Last'], disp: 'First Name'},
		{field: ['Last','First'], disp: 'Last Name'},
		{field: ['TITLE','First','Last'], disp: 'Title'},
		{field: ['COMPANY','First','Last'], disp: 'Company'},
		{field: ['CITY','STATE','First','Last'], disp: 'City'},
		{field: ['STATE','CITY','First','Last'], disp: 'State'}
	];
	$scope.field = $scope.fields[0].field;
	$scope.sort_order = false;
}]).
<commit_msg>index based prefetching (less memory)<commit_after>angular.module('ela', []).

controller('search', ['$scope', '$http', function ($scope, $http) {

	// Initialize user data
	$scope.users = $scope.filtered_users = [];
	$http.get('search.php').then(function (res) {
		$scope.users = res.data;

		angular.forEach($scope.users, function (value) {
			value.Bio = value.First + /*' ' + value.Last +*/ ' ' + value.Bio;
		});

		// Image Pre-loader
		(function (queue, mapper) {
			mapper = mapper || function (obj) { return obj; };
			var image = new Image(), index = 0;
			image.onload = function () {
				if (index < queue.length) image.src = mapper( queue[index++] );
			};
			image.onerror = function (e) {
				console.log(e);
				image.onload();
			};
			image.onload();
		})( $scope.users, function (obj) { return 'img/' + obj.Last + ', ' + obj.First + '.jpg'; } );
	});

	// Searching
	$scope.total_rows = function () {
		var tail = ($scope.filtered_users.length == $scope.users.length) ? '' : (' of ' + $scope.users.length);
		return 'Total: ' + $scope.filtered_users.length + tail;
	};

	// Pagination
	$scope.limits = [5,10,25,50,100];
	$scope.limit = $scope.limits[0];
	$scope.page = 1;
	$scope.pages = function () {
		return Math.ceil( $scope.filtered_users.length / $scope.limit ) || 1;
	};

	// Order By
	$scope.fields = [
		{field: ['First','Last'], disp: 'First Name'},
		{field: ['Last','First'], disp: 'Last Name'},
		{field: ['TITLE','First','Last'], disp: 'Title'},
		{field: ['COMPANY','First','Last'], disp: 'Company'},
		{field: ['CITY','STATE','First','Last'], disp: 'City'},
		{field: ['STATE','CITY','First','Last'], disp: 'State'}
	];
	$scope.field = $scope.fields[0].field;
	$scope.sort_order = false;
}]).

{'fraction_non_alphanumeric': 0.2288013797068123, 'fraction_numerical': 0.008335728657660248, 'mean_word_length': 3.6586345381526106, 'pattern_counts': {'":': 0, '<': 4, '<?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': '147219', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1215, 'n_words': 246}