Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Saturday': null
};
var today = new Date().setHours(0, 0, 0, 0);
today = moment(today);
var lastSaturday = today.clone().startOf('week').subtract(1, 'day');
for (var i=6; i>=0; i--) {
var day = lastSaturday.clone().subtract(i, 'days');
var dateString = day.format('YYYY-MM-DD');
var querySql = "SELECT * FROM datapoints where DATE(time) = DATE('') ORDER BY time desc"
.replace(/\/g, dateString);
promises.push(sequelize.query(querySql, {model: DataPoint}))
}
deferred.apply(deferred, promises).then(function() {
var results = arguments[0];
var resp = {};
_.each(results, function(dps) {
var dps = smoothenData(dps);
var avg = dps.map(function(dp) {
return dp.variance
}).reduce(function(prev, next) {
return prev + next;
}) / dps.length;
var day = moment(dps[0].time).format('dddd');
resp[day] = {average: avg};
});
dfd.resolve(resp);
}).catch(function(){
dfd.resolve();
allRequestsSent.promise.then(function(requests) {
deferred.apply(deferred, requests).then(function() {
var stories = arguments[0];
var diff = false;
var currentIds = stories.map(function(story) {
return story.id;
});
var arrdiff = arrayDiff(prevStories, currentIds);
if (prevStories.length && (arrdiff.insertions.length || arrdiff.deletions.length)) {
diff = true;
}
var totalScore = stories.map(function(story) {
var score = story.score + story.descendants;
return score ? score : 0;