use _.uniq

This commit is contained in:
Barış Soner Uşaklı
2017-06-25 20:00:05 -04:00
parent c36f25f761
commit 38af651072
12 changed files with 40 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
'use strict';
var async = require('async');
var _ = require('lodash');
var db = require('../database');
var posts = require('../posts');
@@ -152,9 +153,7 @@ module.exports = function (User) {
}, next);
},
function (pids, next) {
pids = pids.upvotedPids.concat(pids.downvotedPids).filter(function (pid, index, array) {
return pid && array.indexOf(pid) === index;
});
pids = _.uniq(pids.upvotedPids.concat(pids.downvotedPids).filter(Boolean));
async.eachSeries(pids, function (pid, next) {
posts.unvote(pid, uid, next);