diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index ad85f1d7..f07c065f 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -512,44 +512,41 @@ long WrenchJobsInterestStats(CVars in, CVars &out) { float x = 0.61; char buf[10]; - sprintf(buf, "Test=%.2f", x); - printf(buf); + try { + out["job_completed"] = "0"; + out["job_active"] = "0"; + out["job_percent_complete"] = "0.0 %"; + out["job_uncompleted"] = "0"; + out["job_rejected"] = "0"; + out["job_pending"] = "0"; + out["job_last_date"] = "0000-00-00"; -try { - out["job_completed"] = "0"; - out["job_active"] = "0"; - out["job_percent_complete"] = "0.0 %"; - out["job_uncompleted"] = "0"; - out["job_rejected"] = "0"; - out["job_pending"] = "0"; - out["job_last_date"] = "0000-00-00"; + REQ_STRING(in, "uid", 1, 95, "(.*)"); //uid + REQ_STRING(in, "interest_uid", 1, 95, "(.*)"); //interest_uid + REQ_STRING(in, "client_uid", 1, 95, "(.*)"); //client_uid - REQ_STRING(in, "uid", 1, 95, "(.*)"); //uid - REQ_STRING(in, "interest_uid", 1, 95, "(.*)"); //interest_uid - REQ_STRING(in, "client_uid", 1, 95, "(.*)"); //client_uid + if (load_db_record(out, "SELECT id as client_id FROM members WHERE uid::text = '%s' ", in["client_uid"].c_str())) { - if (load_db_record(out, "SELECT id as client_id FROM members WHERE uid::text = '%s' ", in["client_uid"].c_str())) { + load_db_record(out, "SELECT count(id) AS job_pending FROM members_jobs_offer WHERE client_id = %lu AND expire > now()", out["client_id"].Long()); //pending jobs + load_db_record(out, "SELECT count(id) job_active FROM members_jobs_contract WHERE client_id = %lu AND delivery_date> now() AND status = 1", out["client_id"].Long()); //job_active + load_db_record(out, "SELECT delivery_date::date AS job_last_date FROM members_jobs_contract WHERE client_id = %lu AND status =7 ORDER BY delivery_date DESC LIMIT 1", out["client_id"].Long()); //job_active - load_db_record(out, "SELECT count(id) AS job_pending FROM members_jobs_offer WHERE client_id = %lu AND expire > now()", out["client_id"].Long()); //pending jobs - load_db_record(out, "SELECT count(id) job_active FROM members_jobs_contract WHERE client_id = %lu AND delivery_date> now() AND status = 1", out["client_id"].Long()); //job_active - load_db_record(out, "SELECT delivery_date::date AS job_last_date FROM members_jobs_contract WHERE client_id = %lu AND status =7 ORDER BY delivery_date DESC LIMIT 1", out["client_id"].Long()); //job_active + load_db_record(out, "SELECT count(id) AS total_complete FROM members_jobs_contract WHERE client_id = %lu AND status =7", out["client_id"].Long()); //pending jobs + if ( out["total_complete"].Long() > 0 ){ + load_db_record(out, "SELECT count(id) AS total_jobs FROM members_jobs_contract WHERE client_id = %lu AND ststus IN (7,4,5)", out["client_id"].Long()); //pendi + sprintf(buf, "%.2f %", 100* out["total_complete"].Long() / out["total_jobs"].Long()); + out["job_percent_complete"] = buf; + } - load_db_record(out, "SELECT count(id) AS total_complete FROM members_jobs_contract WHERE client_id = %lu AND status =7", out["client_id"].Long()); //pending jobs - if ( out["total_complete"].Long() > 0 ){ - load_db_record(out, "SELECT count(id) AS total_jobs FROM members_jobs_contract WHERE client_id = %lu AND ststus IN (7,4,5)", out["client_id"].Long()); //pendi - sprintf(buf, "%.2f %", 100* out["total_complete"].Long() / out["total_jobs"].Long()); - out["job_percent_complete"] = buf; + } + // SELECT id as client_id FROM members WHERE uid::text = 'dfc9d601-780f-4d78-839f-422f0928f911'; + // SELECT count(id), status FROM members_jobs_contract WHERE client_id = 2 GROUP BY status; + ret = PHP_CREATED_OK; + } catch (bad_parameter) { + out["log_status"] = "Error WrenchJobsInterestStats"; } - } - // SELECT id as client_id FROM members WHERE uid::text = 'dfc9d601-780f-4d78-839f-422f0928f911'; - // SELECT count(id), status FROM members_jobs_contract WHERE client_id = 2 GROUP BY status; - ret = PHP_CREATED_OK; - } catch (bad_parameter) { - out["log_status"] = "Error WrenchJobsInterestStats"; - } - return ret; }