/*
Script for sending campaign update over 1 min Timeinterval

Author: Saurabh Singh
Lead By : Tarun Anand
Date: 17 Feb, 2018
** Data get from mongo and then Check Delay over Keen every min and send Silent push over devices which lies in the given Time Frame
*/

var campaignCommon = {},
campaignDelay=require('./campaign.delay.js')
    moment = require('moment'),
    semusiConfig = require('./../config'),
    logger = require('../../logger'),
    common = require('./common'),
    gcm = require('node-gcm'),
    cacheApi = require('./semusi.cache.js');

    //get Data from Mongo with status Active and Delay in campaign
(function (campaignDelay) {
    campaignDelay.validateCampaignUser = function(appid){
        common.db.collection('campaigns_'+appid).find({st:"ACTIVE",delays:1,nm:"aman10"}).toArray(function(error, result){
            if(error){
                logger.error(`error=> ${error}`);  
            }else{
                logger.info(`result =>> ${result}`);
                keen.getEvents =  function(appid){
                    proxy.get(semusiConfig.keen.Url + semusiConfig.keen.ProjectId + "/events", function(result,response) {
                        logger.info(`result ${result} && response =>> ${response}`);         
                           
                    });
                };
            }
        }); 
    }  
    campaignDelay.validateCampaignUser('5a6861674a9a74ae4225fc29');
}(campaignDelay));
module.exports = campaignDelay;