removed duplication from train disruption

This commit is contained in:
Martin Donnelly 2016-02-16 16:30:18 +00:00
parent 658bbea5a4
commit 103ef6046b

View File

@ -8,6 +8,7 @@ var log4js = require('log4js');
var logger = log4js.getLogger();
var calHandler = require('./calHandler');
var todayCache = {
last: 0,
data: {
@ -221,9 +222,15 @@ module.exports = {
// join arrays
for (var i = 0; i < outputArray.length; i++) {
var p = todayCache.data.trains.data.indexOf(outputArray[i].title);
console.log('P: ' + p);
todayCache.data.trains.data.push(outputArray[i])
var flag=false;
for (var j = 0; j < todayCache.data.trains.data.length;j++)
{
flag = _.isEqual(todayCache.data.trains.data[j], outputArray[i])
}
if (!flag) {
todayCache.data.trains.data.push(outputArray[i]);
}
}
todayCache.data.trains.data = _.uniq(todayCache.data.trains.data);