<commit_before>
var ddb = require('../../config/dynamo_database').ddb;
var ratingModel = require('../model/ratingModel');

multipleFindBlindRatings = function(resolve, reject, options, result){
	return ddb.scan('blindRatings', options, function (err, ratings) {
		if (!err){
			if(result == undefined)
				result = ratings.items;
			else
				result = _.union(result, ratings.items);
			if(ratings.lastEvaluatedKey.hash == undefined){
				return resolve(result);
			}else{
				options.exclusiveStartKey = {hash: ratings.lastEvaluatedKey.hash, range : ratings.lastEvaluatedKey.range};
				multipleFindBlindRatings(resolve,reject,options, result);
			}
		}else {
			return reject(err);
		}
	});
};


exports.update = function(req,res){
	var ratings = ratingModel.newRating(req);

	ddb.putItem('blindRatings', ratings, {}, function (err) {
		if (!err) {
			var promise = new Promise(function(resolve, reject){
				multipleFindBlindRatings(resolve,reject, {filter : { username: { eq: req._passport.session.user }}});
			});<commit_msg>Resolvendo o problema da Amazon para retorno de votação de propostas<commit_after>
var ddb = require('../../config/dynamo_database').ddb;
var ratingModel = require('../model/ratingModel');
var Promise = require('promise');
var _ = require("underscore");

multipleFindBlindRatings = function(resolve, reject, options, result){
	return ddb.scan('blindRatings', options, function (err, ratings) {
		if (!err){
			if(result == undefined)
				result = ratings.items;
			else
				result = _.union(result, ratings.items);
			if(ratings.lastEvaluatedKey.hash == undefined){
				return resolve(result);
			}else{
				options.exclusiveStartKey = {hash: ratings.lastEvaluatedKey.hash, range : ratings.lastEvaluatedKey.range};
				multipleFindBlindRatings(resolve,reject,options, result);
			}
		}else {
			return reject(err);
		}
	});
};


exports.update = function(req,res){
	var ratings = ratingModel.newRating(req);

	ddb.putItem('blindRatings', ratings, {}, function (err) {
		if (!err) {
			var promise = new Promise(function(resolve, reject){
				multipleFindBlindRatings(resolve,reject, {filter : { username: { eq: req._passport.session.user }}});
			});
{'fraction_non_alphanumeric': 0.14954128440366973, 'fraction_numerical': 0.0, 'mean_word_length': 4.6945169712793735, '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': '1976296', 'n_tokens_mistral': 774, 'n_tokens_neox': 676, 'n_words': 143}