diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index ee592551..7657b9db 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -198,7 +198,9 @@ long RefreshPromoActivities(CVars in, CVars &out){ long ret = PHP_API_BAD_PARAM; try { out["total_record"] = "0"; - const PGresult *res; + const PGresult *res, *resF; + + // check if pending res = pgsql_query("SELECT * FROM promo_member WHERE status = 1 ORDER BY id DESC LIMIT 20"); if (res != NULL && pgsql_num_rows(res) > 0) { out["total_record"] = pgsql_num_rows(res); @@ -209,11 +211,35 @@ long RefreshPromoActivities(CVars in, CVars &out){ CVars rec; map_to_cvars(f, rec); + // check if on pending table + resF = pgsql_query("SELECT status FROM members_pending where LOWER(username)= LOWER('%s')", rec["email"].c_star()); + if (resF != NULL && pgsql_num_rows(resF) > 0) { + pgsql_query("UPDATE promo_member SET updated = now(), status=2 WHERE id = %lu ", rec["id"].Long()); // mo + } + } + } + // check if signup + res = pgsql_query("SELECT * FROM promo_member WHERE status = 2 ORDER BY id DESC LIMIT 20"); + if (res != NULL && pgsql_num_rows(res) > 0) { + out["total_record"] = pgsql_num_rows(res); + + 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); + + // check if on pending table + resF = pgsql_query("SELECT status FROM members where LOWER(username)= LOWER('%s')", rec["email"].c_star()); + if (resF != NULL && pgsql_num_rows(resF) > 0) { + pgsql_query("UPDATE promo_member SET updated = now(), status=3 WHERE id = %lu ", rec["id"].Long()); // mo + } } } + // send reports to admins res = pgsql_query("SELECT * FROM promo_admin WHERE status = 1 ORDER BY updated ASC LIMIT 20"); if (res != NULL && pgsql_num_rows(res) > 0) { out["total_record"] = pgsql_num_rows(res);