Commit 70894af1 authored by ganjingcun's avatar ganjingcun

random return vote

parent 15cd54e1
...@@ -951,9 +951,9 @@ router.get('/vote', function (req, res) { ...@@ -951,9 +951,9 @@ router.get('/vote', function (req, res) {
}, },
function (rows, ids, callback) { function (rows, ids, callback) {
console.log(ids) // console.log(ids)
var validRow = rows.filter(function (row) { var validRow = rows.filter(function (row) {
console.log(row, ids.indexOf(row.id.toString())) // console.log(row, ids.indexOf(row.id.toString()))
return ids.indexOf(row.id.toString()) === -1 return ids.indexOf(row.id.toString()) === -1
}) })
callback(null, validRow); callback(null, validRow);
...@@ -965,8 +965,9 @@ router.get('/vote', function (req, res) { ...@@ -965,8 +965,9 @@ router.get('/vote', function (req, res) {
} }
if (validRow.length > 0) { if (validRow.length > 0) {
var index = _.random(0,validRow.length)
res.json({ res.json({
data: validRow[0] data: validRow[index]
}); });
} else { } else {
res.json({ res.json({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment