filter falsy events first

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 92c58cc62f
commit 4859e499e4

@ -47,16 +47,14 @@ var utils = require('../public/src/utils');
db.getObjects(keys, next); db.getObjects(keys, next);
}, },
function (eventsData, next) { function (eventsData, next) {
eventsData = eventsData.filter(Boolean);
addUserData(eventsData, 'uid', 'user', next); addUserData(eventsData, 'uid', 'user', next);
}, },
function (eventsData, next) { function (eventsData, next) {
addUserData(eventsData, 'targetUid', 'targetUser', next); addUserData(eventsData, 'targetUid', 'targetUser', next);
}, },
function (eventsData, next) { function (eventsData, next) {
eventsData.filter(function (element) { eventsData.forEach(function (event) {
return element !== undefined;
})
.forEach(function (event) {
Object.keys(event).forEach(function (key) { Object.keys(event).forEach(function (key) {
if (typeof event[key] === 'string') { if (typeof event[key] === 'string') {
event[key] = validator.escape(String(event[key] || '')); event[key] = validator.escape(String(event[key] || ''));
@ -103,9 +101,7 @@ var utils = require('../public/src/utils');
map[user.uid] = user; map[user.uid] = user;
}); });
eventsData.filter(function (element) { eventsData.forEach(function (event) {
return element !== undefined;
}).forEach(function (event) {
if (map[event[field]]) { if (map[event[field]]) {
event[objectName] = map[event[field]]; event[objectName] = map[event[field]];
} }

Loading…
Cancel
Save