diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index 71501667..31ed8bef 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -162,6 +162,10 @@ enum { PARTNER_STRIPE }; #define WRB_CRONJOB_NOTIFICATIONS 777 #define WRB_CRONJOB_GROUPJOBS 778 +#define WRB_CRONJOB_TESTNOTIFICATIONS 779 +#define WRB_CRONJOB_SCHEULETRANSFER 780 +#define WRB_CRONJOB_PROCESSTRANSFER 781 + #define WRB_CRONJOB_PENDINGSM 790 //************************************************************** diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index 9da74819..0705df4f 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -28,6 +28,9 @@ long CronTracker(CVars in, CVars &out); long SendMoneyPending(CVars in, CVars &out); long ProcessGroupJobs(CVars in, CVars &out); +long ProcessTransferJobs(CVars in, CVars &out); +long ScheduleTransferJobs(CVars in, CVars &out); +long TestNotificationsJobs(CVars in, CVars &out); /* CREATE TABLE cron_jobs ( id SERIAL, @@ -109,10 +112,31 @@ long sitecrons_calls(CVars in, CVars &out) { break; case WRB_CRONJOB_GROUPJOBS: - ct["job_type"]="WRB_CRONJOB_GROUPJOBS"; ct["job_type"].set_valid( true ); - ct["description"]="Job Group Processing"; ct["description"].set_valid( true ); - CronTracker(ct, co); - return ProcessGroupJobs(in, out); + ct["job_type"]="WRB_CRONJOB_GROUPJOBS"; ct["job_type"].set_valid( true ); + ct["description"]="Job Group Processing"; ct["description"].set_valid( true ); + CronTracker(ct, co); + return ProcessGroupJobs(in, out); + break; + + case WRB_CRONJOB_TESTNOTIFICATIONS: + ct["job_type"]="WRB_CRONJOB_TESTNOTIFICATIONS"; ct["job_type"].set_valid( true ); + ct["description"]="Test Notifications Processing"; ct["description"].set_valid( true ); + CronTracker(ct, co); + return TestNotificationsJobs(in, out); + break; + + case WRB_CRONJOB_SCHEULETRANSFER: + ct["job_type"]="WRB_CRONJOB_SCHEULETRANSFER"; ct["job_type"].set_valid( true ); + ct["description"]="Schedule Transfer Processing"; ct["description"].set_valid( true ); + CronTracker(ct, co); + return ScheduleTransferJobs(in, out); + break; + + case WRB_CRONJOB_PROCESSTRANSFER: + ct["job_type"]="WRB_CRONJOB_PROCESSTRANSFER"; ct["job_type"].set_valid( true ); + ct["description"]="Process Transfer Processing"; ct["description"].set_valid( true ); + CronTracker(ct, co); + return ProcessTransferJobs(in, out); break; } @@ -121,6 +145,34 @@ long sitecrons_calls(CVars in, CVars &out) { return ret; } + +long ProcessTransferJobs(CVars in, CVars &out){ +// if ( load_db_record(out, "SELECT count(uid) AS pending_count FROM money_transfer WHERE status =1 AND completed IS NULL ")> 0){ +// if ( out["pending_count"].Long() > 0 ){ +// alert_email(WRB_CRONJOB_PENDINGSM,out, out); +// } +// } +return 0; +} + +long ScheduleTransferJobs(CVars in, CVars &out){ +// if ( load_db_record(out, "SELECT initiatingamount, status, added,proc FROM money_transfer WHERE added > (now() - interval '3000 minutes') AND status = 0 ORDER BY id DESC LIMIT 100 ")> 0){ +// if ( out["pending_count"].Long() > 0 ){ +// alert_email(WRB_CRONJOB_PENDINGSM,out, out); +// } +// } +return 0; +} + +long TestNotificationsJobs(CVars in, CVars &out){ +// if ( load_db_record(out, "SELECT count(uid) AS pending_count FROM money_transfer WHERE status =1 AND completed IS NULL ")> 0){ +// if ( out["pending_count"].Long() > 0 ){ +// alert_email(WRB_CRONJOB_PENDINGSM,out, out); +// } +// } +return 0; +} + long SendMoneyPending(CVars in, CVars &out){ if ( load_db_record(out, "SELECT count(uid) AS pending_count FROM money_transfer WHERE status =1 AND completed IS NULL ")> 0){ if ( out["pending_count"].Long() > 0 ){ diff --git a/www-api/app/Controllers/AirFlow.php b/www-api/app/Controllers/AirFlow.php index b1ca3193..dab79ac7 100644 --- a/www-api/app/Controllers/AirFlow.php +++ b/www-api/app/Controllers/AirFlow.php @@ -9,7 +9,11 @@ define('WRB_CRONJOB_PASTDUE_ALERT',774); define('WRB_CRONJOB_OFFER_REFUND_ALERT',775); define('WRB_CRONJOB_PENDOFFER_ALERT',776); define('WRB_CRONJOB_NOTIFICATIONS', 777) ; -define('WRB_CRONJOB_GROUPJOBS', 778) ; +define('WRB_CRONJOB_GROUPJOBS', 778); +define('WRB_CRONJOB_TESTNOTIFICATIONS', 779); +define('WRB_CRONJOB_SCHEULETRANSFER', 780); +define('WRB_CRONJOB_PROCESSTRANSFER', 781); + define('WRB_CRONJOB_PENDINGSM', 790) ; class AirFlow extends BaseController @@ -76,6 +80,11 @@ class AirFlow extends BaseController $in = json_decode($raw_json, true); $out =[]; log_message('critical', "AirFlow::flowProcessTransfer ********* ALL ".serialize($in) ); + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + $in['call_action'] = WRB_CRONJOB_PROCESSTRANSFER; + $in['one_limit'] = 10; //remove this + $in['limit'] = 10; + $ret['WRB_CRONJOB_PROCESSTRANSFER'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out); return []; //json_encode( $final_out ); } @@ -84,16 +93,27 @@ class AirFlow extends BaseController $raw_json = file_get_contents('php://input'); $in = json_decode($raw_json, true); $out =[]; + // ALTER TABLE money_transfer ADD proc INT DEFAULT 0; + // SELECT initiatingamount, status, added,proc FROM money_transfer WHERE added > (now() - interval '3000 minutes') AND status = 0 ORDER BY id DESC LIMIT 100; log_message('critical', "AirFlow::flowScheduleTransfer ********* ALL ".serialize($in) ); + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + $in['call_action'] = WRB_CRONJOB_SCHEULETRANSFER; + $in['one_limit'] = 10; //remove this + $in['limit'] = 10; + $ret['WRB_CRONJOB_SCHEULETRANSFER'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out); return []; //json_encode( $final_out ); } - public function flowTestNotifications(){ $raw_json = file_get_contents('php://input'); $in = json_decode($raw_json, true); $out =[]; log_message('critical', "AirFlow::flowTestNotifications ********* ALL ".serialize($in) ); + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + $in['call_action'] = WRB_CRONJOB_TESTNOTIFICATIONS; + $in['one_limit'] = 10; //remove this + $in['limit'] = 10; + $ret['WRB_CRONJOB_TESTNOTIFICATIONS'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out); return []; //json_encode( $final_out ); }