diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index f4cb2fc7..2ab513bf 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -111,6 +111,7 @@ long NotificationSystem(CVars in, CVars &out){ long limit = in["limit"].Long(); logfmt(logINFO, "ENTER NotificationSystem()"); long push_ret = -1; + long status = 0; const PGresult *res = pgsql_query("SELECT count(member_uid) AS mcount,member_uid " " FROM members_notification WHERE status=1 GROUP BY member_uid LIMIT %lu",limit); if (res != NULL && pgsql_num_rows(res) > 0) { @@ -123,6 +124,9 @@ long NotificationSystem(CVars in, CVars &out){ if ( load_db_record(out, "SELECT id AS notification_id, uid,member_uid,msg FROM members_notification " " WHERE status =1 AND member_uid = '%s' ORDER BY id DESC LIMIT 1", rec["member_uid"].c_str())> 0){ + pgsql_query("UPDATE members_notification SET status=2 " + " WHERE id = %lu", status,out["notification_id"].Long()); // move the status so no retry + CVars xx; xx["member_uid"] = out["member_uid"]; xx["member_uid"].set_valid( true ); xx["push_text"] = out["msg"]; xx["push_text"].set_valid( true ); @@ -130,13 +134,15 @@ long NotificationSystem(CVars in, CVars &out){ if (push_ret == PHP_API_OK){ xx["send_result"] = "COMPLETED"; xx["send_result"].set_valid( true ); + status = 5; } else { xx["send_result"] = "FAIL"; xx["send_result"].set_valid( true ); + status = 7; } - pgsql_query("UPDATE members_notification SET send=now(), send_result='%s' " - " WHERE id = %lu", out["notification_id"].Long(),xx["send_result"].c_str()); + pgsql_query("UPDATE members_notification SET send=now(), send_result='%s', status=%lu " + " WHERE id = %lu",xx["send_result"].c_str(), status,out["notification_id"].Long()); } } // for loopp } // main nserach diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index bd5610d1..70b0d85d 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -226,7 +226,7 @@ $routes->post('/en/wrench/api/v1/cron', 'WrenchCrons::apigate'); $routes->get('/en/wrench/api/v1/cron', 'WrenchCrons::apigate'); $routes->get('/en/wrench/api/v1/cron_jobalerts', 'WrenchCrons::jobalerts'); -$routes->get('/en/wrench/api/v1/cron_notifications', 'WrenchCrons::notifications'); +$routes->get('/en/wrench/api/v1/notifications', 'WrenchCrons::cron_notifications'); $routes->get('/en/wrench/api/v1/offersreminders', 'WrenchCrons::offersreminders');