From cc2afc9cd44732e7ae2d47109bbfc36ca7aed159 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 3 Feb 2024 17:30:53 -0500 Subject: [PATCH] assign taskn --- wrenchboard/src/shared_tool/jobs.cc | 3 +- wrenchboard/src/shared_tool/site_crons.cc | 36 +++++++++++++++++++++++ www-api/app/Controllers/WrenchApi.php | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index cac15938..3463eb9b 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -1610,6 +1610,7 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) { REQ_LONG(in, "group_id", 1, -1); //REQ_STRING (in, "email", 1, 59, "(.*)"); REQ_STRING(in, "job_description", 1, 5000, "(.*)"); + long bypass = REQ_LONG(in, "bypass", 1, -1); srand((unsigned) time(NULL)); int r = rand(); @@ -1676,7 +1677,7 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) { logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long() * total_member, z["amount"].Long()); - if (total_member > 2 ){ + if (total_member > 2 && bypass == 0 ){ // REQ_LONG(in, "member_id", 1, -1); // REQ_LONG(in, "job_id", 1, -1); // REQ_LONG(in, "group_id", 1, -1); diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index af013678..9b0a3e10 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -131,7 +131,43 @@ return 0; } long ProcessGroupJobs(CVars in, CVars &out){ + long ret = 0; + long limit = in["limit"].Long(); + logfmt(logINFO, "ENTER ProcessGroupJobs()"); + long push_ret = -1; + long status = 0; + CVars outx; + const PGresult *res = pgsql_query("SELECT * FROM group_offer_schedule WHERE status = 0 ORDER BY ID ASC LIMIT %lu",limit); + if (res != NULL && pgsql_num_rows(res) > 0) { + for (int i = 0, n = pgsql_num_rows(res); i < n; i++) { + mapf = pgsql_fetch_assoc(res, i); + if (f.empty()) continue; + CVars rec; + map_to_cvars(f, rec); + + pgsql_query("UPDATE group_offer_schedule SET status= 1 " + " WHERE id = %lu AND uid = '%s'", rec["id"].Long(),rec["uid"].c_str()); // move the status so no retry + + if ( load_db_record(outx, "SELECT * FROM group_offer_schedule " + " WHERE status = 1 AND uid = '%s' ORDER BY id DESC LIMIT 1", rec["uid"].c_str())> 0){ + + pgsql_query("UPDATE group_offer_schedule SET status= 2 " + " WHERE id = %lu AND uid = '%s'", rec["id"].Long(),rec["uid"].c_str()); // move the status so no retry + + CVars xx; + xx["bypass"] = "1000"; + xx["member_uid"] = outx["member_id"]; xx["member_id"].set_valid( true ); + xx["job_id"] = outx["job_id"]; xx["job_id"].set_valid( true ); + xx["group_id"] = outx["group_id"]; xx["group_id"].set_valid( true ); + xx["job_description"] = outx["job_description"]; xx["job_description"].set_valid( true ); + WrenchSendJobsOfferGroup( xx, out); + + pgsql_query("UPDATE group_offer_schedule SET completed=now(), notes='%s', status= 5 " + " WHERE id = %lu AND uid='%s'",out["status_msg"].c_str(), rec["id"].Long(),rec["uid"].c_str() ); + } + } // for loopp + } // main nserach return 0; } diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index 02bc6ffb..54f9afc8 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -110,6 +110,7 @@ class WrenchApi extends BaseController break; case 'assigntask': + $in["bypass"] = 0; $in["action"] = WRENCHBOARD_JOB_OFFER_SYSTEM; break;