
var eventString = require('./eventString_version_final.js')

	//fetch previous dates
    function fetchDate(currentDate){
        var finalDate = currentDate
        //if month is less than 10, it returns single digit, converting it to required format
        if((finalDate.getMonth()+1)<10){
            var final = finalDate.getFullYear()+"-0"+(finalDate.getMonth()+1)
        }
        else{
            var final = finalDate.getFullYear()+"-"+(finalDate.getMonth()+1)
        }
        //if date is less than 10, it returns single digit, converting it to required format
        if(finalDate.getDate()<10){
            final = final + "-0" + finalDate.getDate();
        }
        else{
            final = final + "-" + finalDate.getDate();
        }
        return final;
    }

    //compute date of previous date
    var currentDate = new Date();	//current date 
    var processDate = new Date();	//date used to compute previous date
    var day = currentDate.getDate();
    //if date is less than 10, it returns single digit, converting it to required format
    if(day<10){
        day = "0" + day
    }
    //if month is less than 10, it returns single digit, converting it to required format
    var month = currentDate.getMonth() + 1;
    if(month<10){
        month = "0" + month
    }

    var year = currentDate.getFullYear();
    //making date in required format YYYY-MM-DD
    var today = year + "-" + month + "-" + day
     
    var todayDate = new Date(today);	
    //setting date to previous date
    processDate.setDate(todayDate.getDate()-1)
    var yesterday = fetchDate(processDate)
     
    var dateArray = yesterday.split('-')
    var tabledate = dateArray[2] + dateArray[1] + dateArray[0];
    var columnDate = dateArray[2] + dateArray[1] + '20';
    var mon = currentDate.getMonth() + 1;

var  app_id = '5ad83ce1f71de7016db4c0c1'  

var params = {
	'eventTable' : "events_"+ app_id +"_01102020",
	'eventPartition' : "events_"+ app_id,
	'date': '2020-10-01',
	'appEventTable' : "app_events_" + app_id,
	'appUsersTable' : "app_users_" + app_id,
	'sessionTable' :'sessions_' + app_id,
	'attributeTable' : 'attributes_' + app_id,
	'attributeValueTable' : 'attribute_value_' + app_id+ '0',
	'countStatusTable' : 'eventCountStatus_' + app_id,
	'eventStringTable' : 'eventstringsept_' + app_id,
	'eventStringColumn' : 'eventstring',
	'eventStringCurrentColumn' : 'es011020',
}

eventString.eventStringCron(params);