<commit_before>var occurrencesES = require("../../models/elasticsearch/occurrencesModel");
var _ = require('underscore');

exports.getFichaDetailsOrSearchFichas = function(req, res) {
	if(req.params._fichaid === "search") {
		occurrences = occurrencesES.searchFichas(req.query.q, req.query.pagesize, req.query.page, req.query.order, req.query.sort, req.query.department, req.query.taxonomy, req.query.collection);
	} else if(req.params._fichaid === "random") {
		occurrences = occurrencesES.getRandomFichas(req.query.pagesize, req.query.page);
	} else {
		occurrences = occurrencesES.getFicha(req.params._fichaid);
	}
	occurrences.exec(function(err, data){
		if(JSON.parse(data).error) {
			res.jsonp(JSON.parse(data));	
		} else {
			res.jsonp(JSON.parse(data).hits);
		}
	});
};

exports.getCountFichas =  function(req, res) {
	occurrences = occurrencesES.getTotalFichas();
	occurrences.exec(function(err, data){
		res.jsonp(JSON.parse(data).count);
	});
};

exports.listFichas = function(req, res) {
	console.log("sooopas");
	occurrences = occurrencesES.getListFichas(req.query.pagesize, req.query.page);
	occurrences.exec(function(err, data){
		res.jsonp(JSON.parse(data).hits);
	});
};<commit_msg>Remove invalid comment<commit_after>var occurrencesES = require("../../models/elasticsearch/occurrencesModel");
var _ = require('underscore');

exports.getFichaDetailsOrSearchFichas = function(req, res) {
	if(req.params._fichaid === "search") {
		occurrences = occurrencesES.searchFichas(req.query.q, req.query.pagesize, req.query.page, req.query.order, req.query.sort, req.query.department, req.query.taxonomy, req.query.collection);
	} else if(req.params._fichaid === "random") {
		occurrences = occurrencesES.getRandomFichas(req.query.pagesize, req.query.page);
	} else {
		occurrences = occurrencesES.getFicha(req.params._fichaid);
	}
	occurrences.exec(function(err, data){
		if(JSON.parse(data).error) {
			res.jsonp(JSON.parse(data));	
		} else {
			res.jsonp(JSON.parse(data).hits);
		}
	});
};

exports.getCountFichas =  function(req, res) {
	occurrences = occurrencesES.getTotalFichas();
	occurrences.exec(function(err, data){
		res.jsonp(JSON.parse(data).count);
	});
};

exports.listFichas = function(req, res) {
	occurrences = occurrencesES.getListFichas(req.query.pagesize, req.query.page);
	occurrences.exec(function(err, data){
		res.jsonp(JSON.parse(data).hits);
	});
};
{'fraction_non_alphanumeric': 0.16917922948073702, 'fraction_numerical': 0.0, 'mean_word_length': 5.422043010752688, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7197100', 'n_tokens_mistral': 939, 'n_tokens_neox': 852, 'n_words': 105}