diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index 530178c3..91f3cd25 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -1603,6 +1603,8 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) { logfmt(logINFO, "WrenchSendJobsOfferGroup()"); long ret = PHP_API_BAD_PARAM; + long sum_ret = 0; + REQ_LONG(in, "member_id", 1, -1); REQ_LONG(in, "job_id", 1, -1); REQ_LONG(in, "group_id", 1, -1); @@ -1685,11 +1687,16 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) { jj["job_id"] = in["job_id"]; jj["job_id"].set_valid( true ); jj["group_id"] = in["group_id"]; jj["group_id"].set_valid( true ); jj["job_description"] = in["job_description"]; jj["job_description"].set_valid( true ); + jj["total_member"] = total_member; jj["total_member"].set_valid( true ); out["planned_offer_id"] = insert_db_record(DBS_VALID, "group_offer_schedule", "group_offer_schedule_id_seq", jj); + + out["status_msg"] = "Offer is scheduled to be sent in few minutes"; + ret = PHP_CREATED_OK; + return ret; } - try { + try { const PGresult *res = pgsql_query("SELECT email FROM members_job_groupmember " " WHERE group_id = %lu " " AND member_id = %lu " @@ -1708,11 +1715,21 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) { rec["member_id"] = in["member_id"]; rec["member_id"].set_valid(true); long call_ret = WrenchSendJobsOfferIndividual(rec, out); - + sum_ret = sum_ret + call_ret; // a way to know all came back positive if (call_ret == PHP_CREATED_OK) { ret = PHP_CREATED_OK; } } + + if (call_ret == PHP_CREATED_OK && sum_ret == 0 ) { + out["status_msg"] = "Completed"; + ret = PHP_CREATED_OK; + } + else{ + out["status_msg"] = "Completed with some error"; + ret = sum_ret; + } + } } catch (bad_parameter) { out["log_status"] = "Invalid Log Action";