@@ -20,13 +20,13 @@ const PlanAreaChangesController = require('../controller/plan_area_changes');
2020const getPlanTagger = require ( '../lib/tags' ) ;
2121const PlanStatusChange = require ( '../model/plan_status_change' ) ;
2222const { meirimStatuses } = require ( '../constants' ) ;
23- const { report } = require ( '../../metrics' )
23+ const { report } = require ( '../../metrics' ) ;
2424
2525const iplan = ( limit = - 1 ) =>
2626 iplanApi
2727 . getBlueLines ( )
2828 . then ( iPlans => {
29- report ( { metricName : " iplane.bluelines.count" , value : iPlans . length } )
29+ report ( { metricName : ' iplane.bluelines.count' , value : iPlans . length } ) ;
3030
3131 // limit blue lines found so we output only *limit* plans
3232 if ( limit > - 1 ) {
@@ -35,7 +35,7 @@ const iplan = (limit = -1) =>
3535
3636 return Bluebird . mapSeries ( iPlans , iPlan => fetchIplan ( iPlan ) ) ;
3737 } ) . catch ( e => {
38- Log . error ( ` Error fetching new plans` , e ) ;
38+ Log . error ( ' Error fetching new plans' , e ) ;
3939 } ) ;
4040
4141const fix_geodata = ( ) => {
@@ -69,27 +69,27 @@ const complete_mavat_data = () =>
6969 } )
7070 . fetchAll ( )
7171 . then ( planCollection => {
72- Log . info ( { message : " found incomplete mavat data" , length : planCollection . length } )
72+ Log . info ( { message : ' found incomplete mavat data' , length : planCollection . length } ) ;
7373 return planCollection ;
7474 } )
7575 . then ( planCollection =>
7676
77- Bluebird . mapSeries ( planCollection . models , plan => {
78- Log . info ( { message : " about to work on plan" , id : plan . get ( "id" ) , url : plan . get ( 'plan_url' ) } )
77+ Bluebird . mapSeries ( planCollection . models , plan => {
78+ Log . info ( { message : ' about to work on plan' , id : plan . get ( 'id' ) , url : plan . get ( 'plan_url' ) } ) ;
7979
8080 return MavatAPI . getByPlan ( plan )
8181 . then ( mavatData => {
82- Log . info ( { message : 'Saving with mavat' , data : JSON . stringify ( mavatData ) } ) ;
82+ Log . info ( { message : 'Saving with mavat' , data : JSON . stringify ( mavatData ) } ) ;
8383 return Plan . setMavatData ( plan , mavatData ) . then ( Promise . all ( [ plan . save ( ) ,
8484 PlanAreaChangesController . refreshPlanAreaChanges ( plan . id , plan . attributes . areaChanges )
85- ] ) )
85+ ] ) ) ;
8686 } )
8787 . catch ( ( e ) => {
88- Log . error ( { message : " failure in complete_mavat_data" , e, id : plan . get ( "id" ) } )
88+ Log . error ( { message : ' failure in complete_mavat_data' , e, id : plan . get ( 'id' ) } ) ;
8989 // do nothing on error
9090 } ) . finally ( ( ) => {
91- Log . info ( { message : " finish working on plan" , id : plan . get ( "id" ) } )
92- } )
91+ Log . info ( { message : ' finish working on plan' , id : plan . get ( 'id' ) } ) ;
92+ } ) ;
9393 } )
9494 ) ;
9595
@@ -121,7 +121,7 @@ const sendPlanningAlerts = () => {
121121 limit : 1
122122 } )
123123 . then ( unsentPlans => {
124- report ( { metricName : " planning_alerts.unsent" , value : unsentPlans . models . length } )
124+ report ( { metricName : ' planning_alerts.unsent' , value : unsentPlans . models . length } ) ;
125125 Log . debug ( 'Got' , unsentPlans . models . length , 'Plans' ) ;
126126 return unsentPlans . models ;
127127 } )
@@ -418,17 +418,17 @@ const fetchPlanStatus = () => {
418418 const dateString = moment ( date ) . format ( 'YYYY-MM-DD h:mm' ) ;
419419 return Plan . query ( qb => {
420420 qb . leftJoin ( 'status_mapping' , 'plan.status' , '=' , 'status_mapping.mavat_status' )
421- . whereRaw ( `(status_mapping.meirim_status is null or status_mapping.meirim_status != '${ meirimStatuses . APPROVED } ') and plan.MP_ID NOT LIKE \'NOT_FOUND\' and (plan.last_visited_status < '${ dateString } ' OR plan.last_visited_status IS NULL)` )
422- . orderBy ( 'plan.last_visited_status' , 'asc' ) ;
421+ . whereRaw ( `(status_mapping.meirim_status is null or status_mapping.meirim_status != '${ meirimStatuses . APPROVED } ') and plan.MP_ID NOT LIKE \'NOT_FOUND\' and (plan.last_visited_status < '${ dateString } ' OR plan.last_visited_status IS NULL)` )
422+ . orderBy ( 'plan.last_visited_status' , 'asc' ) ;
423423 qb . limit ( planStatusLimit ) ;
424424 } )
425425 . fetchAll ( )
426426 . then ( planCollection =>
427427 Bluebird . mapSeries ( planCollection . models , plan => {
428428
429429 Log . info ( {
430- planId : plan . get ( "id" ) ,
431- message : " working on plan" ,
430+ planId : plan . get ( 'id' ) ,
431+ message : ' working on plan' ,
432432 last_visited_status : plan . get ( 'last_visited_status' ) ,
433433 status :plan . get ( 'status' ) ,
434434 } ) ;
@@ -461,7 +461,7 @@ const fetchPlanStatus = () => {
461461 return ;
462462 }
463463 const mostRecentStatus = mostRecent [ 0 ] . attributes . status ;
464- Log . info ( { message : 'updating plan status' , status : mostRecentStatus , planId : plan . get ( 'id' ) , oldStatus : plan . get ( 'status' ) } ) ;
464+ Log . info ( { message : 'updating plan status' , status : mostRecentStatus , planId : plan . get ( 'id' ) , oldStatus : plan . get ( 'status' ) } ) ;
465465 await plan . save ( { 'last_visited_status' : now , 'status' : mostRecentStatus } ) ;
466466
467467 // save all plan statuses into plan_status_change table
@@ -475,13 +475,13 @@ const fetchPlanStatus = () => {
475475 await sendEmailIfNeeded ( plan , planStatuses , mavatStatus ) ;
476476 }
477477 catch ( err ) {
478- Log . error ( { err} ) ;
478+ Log . error ( { err } ) ;
479479 const now = moment ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ;
480480 await plan . save ( { 'last_visited_status' : now } ) ;
481481 }
482482 } )
483483 . catch ( async ( err ) => {
484- Log . error ( { err} ) ;
484+ Log . error ( { err } ) ;
485485 const now = moment ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ;
486486 await plan . save ( { 'last_visited_status' : now } ) ;
487487 } ) ;
0 commit comments