<commit_before>'use strict';

let pruneSearchPlayerData = require('./_searchPlayerData');

/**
 * Prunes search results.
 * 
 * @private
 * @param {Object} data - The raw search data to be pruned.
 * @returns {Array} - Pruned player objects, or an empty array if there's nothing to prune.
 */
function pruneSearchResults(data) {
	let hasResults = data.search_player_all.queryResults.totalSize > 0;
	let prunedResults = [];

	if (!hasResults) {
		return prunedResults;
	} else {
		let resultsCount = data.search_player_all.queryResults.totalSize;
		if (resultsCount > 1) {
			let searchResults = data.search_player_all.queryResults.row;
			for (let i = 0; i < searchResults.length; i++) {
				let player = searchResults[i];
				let prunedPlayer = pruneSearchPlayerData(player);
				prunedResults.push(prunedPlayer);
			}
		} else if (resultsCount === 0) {
			let player = data.search_player_all.queryResults.row;
			let prunedPlayer = pruneSearchPlayerData(player);
			prunedResults.push(prunedPlayer);
		}
		return prunedResults;
	}

}

module.exports = pruneSearchResults;<commit_msg>fixed returning pruned player on single results<commit_after>'use strict';

let pruneSearchPlayerData = require('./_searchPlayerData');

/**
 * Prunes search results.
 * 
 * @private
 * @param {Object} data - The raw search data to be pruned.
 * @returns {Array} - Pruned player objects, or an empty array if there's nothing to prune.
 */
function pruneSearchResults(data) {
	let hasResults = data.search_player_all.queryResults.totalSize > 0;
	let prunedResults = [];

	if (!hasResults) {
		return prunedResults;
	} else {
		let resultsCount = data.search_player_all.queryResults.totalSize;
		if (resultsCount > 1) {
			let searchResults = data.search_player_all.queryResults.row;
			for (let i = 0; i < searchResults.length; i++) {
				let player = searchResults[i];
				let prunedPlayer = pruneSearchPlayerData(player);
				prunedResults.push(prunedPlayer);
			}
		} else {
			let player = data.search_player_all.queryResults.row;
			let prunedPlayer = pruneSearchPlayerData(player);
			prunedResults.push(prunedPlayer);
		}
		return prunedResults;
	}

}

module.exports = pruneSearchResults;
{'fraction_non_alphanumeric': 0.10963302752293579, 'fraction_numerical': 0.003211009174311927, 'mean_word_length': 4.306569343065694, 'pattern_counts': {'":': 0, '<': 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': '6249270', 'n_tokens_mistral': 771, 'n_tokens_neox': 679, 'n_words': 170}