refactor(week-from-obj): handling logs
This commit is contained in:
parent
a486b29389
commit
4cdabceb57
|
@ -28,7 +28,9 @@ async function run() {
|
||||||
let count = Object.keys(objRoutes).length;
|
let count = Object.keys(objRoutes).length;
|
||||||
debug('objRoutes count: ' + count);
|
debug('objRoutes count: ' + count);
|
||||||
let aryRoutes =Object.entries(objRoutes);
|
let aryRoutes =Object.entries(objRoutes);
|
||||||
for(var j=0;j<1;j++){
|
let aryWeekTripsCount=[0,0,0,0,0,0,0];
|
||||||
|
debug('aryWeekTripsCount.length: '+aryWeekTripsCount.length);
|
||||||
|
for(var j=0;j<2;j++){
|
||||||
debug('j: '+j);
|
debug('j: '+j);
|
||||||
let routeId=aryRoutes[i][0];
|
let routeId=aryRoutes[i][0];
|
||||||
debug('routeId: ' + routeId);
|
debug('routeId: ' + routeId);
|
||||||
|
@ -38,7 +40,10 @@ async function run() {
|
||||||
let aryTripsCount=[0,0,0,0,0,0,0];
|
let aryTripsCount=[0,0,0,0,0,0,0];
|
||||||
aryTripsCount=routeService.getTripsCountFromRoute(routeShortName,thisWeek);
|
aryTripsCount=routeService.getTripsCountFromRoute(routeShortName,thisWeek);
|
||||||
//TODO Why is aryTripsCount undefined?
|
//TODO Why is aryTripsCount undefined?
|
||||||
debug('aryTripsCount: '+aryTripsCount[0]);
|
debug('aryTripsCount len: '+aryTripsCount.length);
|
||||||
|
for(var k=0;k<aryWeekTripsCount.length;k++){
|
||||||
|
aryWeekTripsCount[k]=aryWeekTripsCount[k]+aryTripsCount[k];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
debug('url: '+url);
|
debug('url: '+url);
|
||||||
let aryTripsCount=[0,0,0,0,0,0,0];
|
let aryTripsCount=[0,0,0,0,0,0,0];
|
||||||
let resp={};
|
let resp={};
|
||||||
resp= await axios.get(url);
|
resp=await axios.get(url);
|
||||||
if('data' in resp){
|
if('data' in resp){
|
||||||
const objServiceDays=resp.data;
|
const objServiceDays=resp.data;
|
||||||
const aryServiceDays=Object.entries(objServiceDays);
|
const aryServiceDays=Object.entries(objServiceDays);
|
||||||
|
@ -31,7 +31,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
dateFromDay=new Date(new Date(dateFromDay).setHours(0, 0, 0, 0));
|
dateFromDay=new Date(new Date(dateFromDay).setHours(0, 0, 0, 0));
|
||||||
//debug('dateFromDay: '+dateFromDay);
|
//debug('dateFromDay: '+dateFromDay);
|
||||||
if(dateFromDay.getTime()===week[0].getTime()){
|
if(dateFromDay.getTime()===week[0].getTime()){
|
||||||
debug('found date 0: '+dateFromDay);
|
//debug('found date 0: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -39,7 +39,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[0]=tripCount;
|
aryTripsCount[0]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[1].getTime()){
|
else if(dateFromDay.getTime()===week[1].getTime()){
|
||||||
debug('found date 1: '+dateFromDay);
|
//debug('found date 1: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -47,7 +47,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[1]=tripCount;
|
aryTripsCount[1]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[2].getTime()){
|
else if(dateFromDay.getTime()===week[2].getTime()){
|
||||||
debug('found date 2: '+dateFromDay);
|
//debug('found date 2: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -55,7 +55,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[2]=tripCount;
|
aryTripsCount[2]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[3].getTime()){
|
else if(dateFromDay.getTime()===week[3].getTime()){
|
||||||
debug('found date 3: '+dateFromDay);
|
//debug('found date 3: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -63,7 +63,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[3]=tripCount;
|
aryTripsCount[3]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[4].getTime()){
|
else if(dateFromDay.getTime()===week[4].getTime()){
|
||||||
debug('found date 4: '+dateFromDay);
|
//debug('found date 4: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -71,7 +71,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[4]=tripCount;
|
aryTripsCount[4]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[5].getTime()){
|
else if(dateFromDay.getTime()===week[5].getTime()){
|
||||||
debug('found date 5: '+dateFromDay);
|
//debug('found date 5: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
@ -79,7 +79,7 @@ async function getTripsCountFromRoute(routeShortName,week) {
|
||||||
aryTripsCount[5]=tripCount;
|
aryTripsCount[5]=tripCount;
|
||||||
}
|
}
|
||||||
else if(dateFromDay.getTime()===week[6].getTime()){
|
else if(dateFromDay.getTime()===week[6].getTime()){
|
||||||
debug('found date 6: '+dateFromDay);
|
//debug('found date 6: '+dateFromDay);
|
||||||
let trips=aryServiceDays[i][1];
|
let trips=aryServiceDays[i][1];
|
||||||
const aryTrip = Object.keys(trips);
|
const aryTrip = Object.keys(trips);
|
||||||
const tripCount=aryTrip.length;
|
const tripCount=aryTrip.length;
|
||||||
|
|
Loading…
Reference in New Issue