<commit_before>transactions = require '../model/transactions'
Q = require 'q'
logger = require 'winston'

###
# Retrieves the list of transactions
###
exports.getTransactions = `function *getTransactions() {
	var filtersObject = this.request.query;

	//construct date range filter option
	if( filtersObject.startDate && filtersObject.endDate ){
		filtersObject['request.timestamp'] = { $gte: filtersObject.startDate, $lt: filtersObject.endDate }

		//remove startDate/endDate from objects filter (Not part of filtering and will break filter)
		delete filtersObject.startDate;
		delete filtersObject.endDate;
	}	

	//get limit and page values
	var filterLimit = filtersObject.filterLimit;
	var filterPage = filtersObject.filterPage;

	//remove limit/page values from filtersObject (Not apart of filtering and will break filter if present)
	delete filtersObject.filterLimit;
	delete filtersObject.filterPage;	

	//determine skip amount
	var filterSkip = filterPage*filterLimit;

	try {
		this.body = yield transactions.Transaction.find(filtersObject).skip(filterSkip).limit(filterLimit).sort({ 'request.timestamp': -1 }).exec();
	}catch (e){
		this.message = e.message;
		this.status = 500;
	}
}`

###
# Adds an transaction  
###
exports.addTransaction = `function *addTransaction() {
	// Get the values to use
	var transactionData = this.request.body;<commit_msg>Updated transactions sort(desc) filter<commit_after>transactions = require '../model/transactions'
Q = require 'q'
logger = require 'winston'

###
# Retrieves the list of transactions
###
exports.getTransactions = `function *getTransactions() {
	var filtersObject = this.request.query;

	//construct date range filter option
	if( filtersObject.startDate && filtersObject.endDate ){
		filtersObject['request.timestamp'] = { $gte: filtersObject.startDate, $lt: filtersObject.endDate }

		//remove startDate/endDate from objects filter (Not part of filtering and will break filter)
		delete filtersObject.startDate;
		delete filtersObject.endDate;
	}	

	//get limit and page values
	var filterLimit = filtersObject.filterLimit;
	var filterPage = filtersObject.filterPage;

	//remove limit/page values from filtersObject (Not apart of filtering and will break filter if present)
	delete filtersObject.filterLimit;
	delete filtersObject.filterPage;	

	//determine skip amount
	var filterSkip = filterPage*filterLimit;

	try {
		this.body = yield transactions.Transaction.find(filtersObject).sort({ 'request.timestamp': -1 }).skip(filterSkip).limit(filterLimit).exec();
	}catch (e){
		this.message = e.message;
		this.status = 500;
	}
}`

###
# Adds an transaction  
###
exports.addTransaction = `function *addTransaction() {
	// Get the values to use
	var transactionData = this.request.body;
{'fraction_non_alphanumeric': 0.11058566751546017, 'fraction_numerical': 0.0029101491451436886, 'mean_word_length': 4.851063829787234, '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': '5802819', 'n_tokens_mistral': 809, 'n_tokens_neox': 771, 'n_words': 228}