diff --git a/wrenchboard/src/shared_tool/reco_egine.cc b/wrenchboard/src/shared_tool/reco_egine.cc index f21dc1e5..cb7bb83b 100644 --- a/wrenchboard/src/shared_tool/reco_egine.cc +++ b/wrenchboard/src/shared_tool/reco_egine.cc @@ -25,12 +25,13 @@ */ long sendOffersRecommendation( CVars in, CVars &out); long sendCouponRecommendation( CVars in, CVars &out); -long RecoCheckOffers( CVars in, CVars &out ); -long RecoCheckFamilyLogin( CVars in, CVars &out ); -long RecoCheckFamilyCount( CVars in, CVars &out ); -long RecoCheckCoupons( CVars in, CVars &out ); -long RecoCheckTaskDue( CVars in, CVars &out ); -long RecoCheckBlog( CVars in, CVars &out ); + +long RecoCheckOffers( int itm_count, CVars in, CVars &out ); +long RecoCheckFamilyLogin( int itm_count, CVars in, CVars &out ); +long RecoCheckFamilyCount( int itm_count, CVars in, CVars &out ); +long RecoCheckCoupons( int itm_count, CVars in, CVars &out ); +long RecoCheckTaskDue( int itm_count, CVars in, CVars &out ); +long RecoCheckBlog( int itm_count, CVars in, CVars &out ); long recommendation_engine(long action , CVars in, CVars &out) { @@ -107,33 +108,219 @@ return 0; } -long RecoCheckOffers( CVars in, CVars &out ){ +long RecoCheckOffers(int itm_count, CVars in, CVars &out ){ + logfmt(logINFO, "RecoCheckOffers()"); + long ret = PHP_API_BAD_PARAM; + const PGresult *res; + char vname[30]; + try { + +// res = pgsql_query("SELECT * FROM members_jobs_offer WHERE expire > now() AND status = 1 AND client_id = %lu ",member_id); +// if (res != NULL && pgsql_num_rows(res) > 0) { +// +// snprintf(vname, sizeof (vname), "title_%05d", ic); +// out[vname] = "This is the offer available text"; +// +// snprintf(vname, sizeof (vname), "description_%05d", ic); +// out[vname] = "This is the offer available text DESCRIPTIOON - This is the offer available text"; +// +// snprintf(vname, sizeof (vname), "card_type_%05d", ic); +// out[vname] = "OFFERS"; +// +// snprintf(vname, sizeof (vname), "offer_id_%05d", ic); +// out[vname] = "0"; +// +// snprintf(vname, sizeof (vname), "blog_id_%05d", ic); +// out[vname] = "0"; +// +// snprintf(vname, sizeof (vname), "card_icon_%05d", ic); +// out[vname] = "icon1"; +// +// snprintf(vname, sizeof (vname), "banner_%05d", i); +// out[vname] ="https://blog.wrenchboard.com/wp-content/uploads/2022/01/wrechboard-sample.jpg"; +// +// ret = PHP_API_OK; +// } + long member_id = REQ_LONG(in, "member_id", 1, -1); + int itm_count= 0; + if( RecoCheckOffers( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + if( RecoCheckFamilyLogin( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + if( RecoCheckFamilyCount( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + if( RecoCheckCoupons( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + //if( RecoCheckTaskDue( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + if( RecoCheckBlog( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } + + } catch (bad_parameter) { + out["status"] = "ERROR"; + } + logfmt(logINFO, "/RecoCheckOffers()"); + return ret; +} + +long RecoCheckFamilyLogin(int itm_count, CVars in, CVars &out ){ + //SELECT count(id) AS family_count FROM members_family WHERE member_id =1 AND status = 1 AND last_login IS NULL ; + logfmt(logINFO, "RecoCheckFamilyLogin()"); + long ret = PHP_API_BAD_PARAM; + const PGresult *res; + char vname[30]; + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); + res = pgsql_query("SELECT count(id) AS family_count FROM members_family WHERE member_id = %lu AND status = 1 AND last_login IS NULL ",member_id); + if (res != NULL && pgsql_num_rows(res) > 0) { + + snprintf(vname, sizeof (vname), "title_%05d", ic); + out[vname] = "This is the family not login text"; + + snprintf(vname, sizeof (vname), "description_%05d", ic); + out[vname] = "his is the family not login text DESCRIPTIOON - This is the offer available text"; + + snprintf(vname, sizeof (vname), "card_type_%05d", ic); + out[vname] = "FAMILY_NOLOGIN"; + + snprintf(vname, sizeof (vname), "offer_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "blog_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "card_icon_%05d", ic); + out[vname] = "icon1"; + + snprintf(vname, sizeof (vname), "banner_%05d", i); + out[vname] ="https://blog.wrenchboard.com/wp-content/uploads/2022/01/wrechboard-sample.jpg"; + + ret = PHP_API_OK; + } + } catch (bad_parameter) { + out["status"] = "ERROR"; + } + logfmt(logINFO, "/RecoCheckFamilyLogin()"); + return ret; +} + +long RecoCheckFamilyCount( int itm_count, CVars in, CVars &out ){ + //SELECT count(id) AS family_count FROM members_family WHERE member_id =1 AND status = 1 AND last_login IS NULL ; + logfmt(logINFO, "RecoCheckFamilyCount()"); + long ret = PHP_API_BAD_PARAM; + const PGresult *res; + char vname[30]; + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); + res = pgsql_query("SELECT count(id) AS family_count FROM members_family WHERE member_id = %lu AND status = 1 AND last_login IS NULL ",member_id); + if (res != NULL && pgsql_num_rows(res) == 0) { + + snprintf(vname, sizeof (vname), "title_%05d", ic); + out[vname] = "You can add your family text"; + + snprintf(vname, sizeof (vname), "description_%05d", ic); + out[vname] = "do you know his is the family not login text DESCRIPTION - This is the offer available text"; + + snprintf(vname, sizeof (vname), "card_type_%05d", ic); + out[vname] = "FAMILY_ADD"; + + snprintf(vname, sizeof (vname), "offer_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "blog_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "card_icon_%05d", ic); + out[vname] = "icon1"; + + snprintf(vname, sizeof (vname), "banner_%05d", i); + out[vname] ="https://blog.wrenchboard.com/wp-content/uploads/2022/01/wrechboard-sample.jpg"; + + ret = PHP_API_OK; + } + } catch (bad_parameter) { + out["status"] = "ERROR"; + } + logfmt(logINFO, "/RecoCheckFamilyCount()"); + return ret; +} + +long RecoCheckCoupons( int itm_count, CVars in, CVars &out ){ + //SELECT id AS coupons_count FROM coupons_allocation WHERE member_id =1 AND amount> 0 AND active IS NULL; + logfmt(logINFO, "RecoCheckCoupons()"); + long ret = PHP_API_BAD_PARAM; + const PGresult *res; + char vname[30]; + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); + res = pgsql_query("SELECT id AS coupons_count FROM coupons_allocation WHERE member_id = %lu AND amount> 0 AND active IS NULL ",member_id); + if (res != NULL && pgsql_num_rows(res) > 0) { + + snprintf(vname, sizeof (vname), "title_%05d", ic); + out[vname] = "Yo man , you have Coupons to play with"; + + snprintf(vname, sizeof (vname), "description_%05d", ic); + out[vname] = "his is the family not login text DESCRIPTIOON - This is the offer available text"; + + snprintf(vname, sizeof (vname), "card_type_%05d", ic); + out[vname] = "FAMILY_NOLOGIN"; + + snprintf(vname, sizeof (vname), "offer_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "blog_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "card_icon_%05d", ic); + out[vname] = "icon1"; + + snprintf(vname, sizeof (vname), "banner_%05d", i); + out[vname] ="https://blog.wrenchboard.com/wp-content/uploads/2022/01/wrechboard-sample.jpg"; + + ret = PHP_API_OK; + } + } catch (bad_parameter) { + out["status"] = "ERROR"; + } + logfmt(logINFO, "/RecoCheckCoupons()"); + return ret; +} + +long RecoCheckTaskDue( int itm_count, CVars in, CVars &out ){ long ret = PHP_API_BAD_PARAM; return ret; } -long RecoCheckFamilyLogin( CVars in, CVars &out ){ +long RecoCheckBlog( int itm_count, CVars in, CVars &out ){ long ret = PHP_API_BAD_PARAM; - return ret; -} + logfmt(logINFO, "RecoCheckBlog()"); + long ret = PHP_API_BAD_PARAM; + const PGresult *res; + char vname[30]; + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); -long RecoCheckFamilyCount( CVars in, CVars &out ){ - long ret = PHP_API_BAD_PARAM; - return ret; -} + snprintf(vname, sizeof (vname), "title_%05d", ic); + out[vname] = "This is the blog title, yes blog title"; -long RecoCheckCoupons( CVars in, CVars &out ){ - long ret = PHP_API_BAD_PARAM; - return ret; -} + snprintf(vname, sizeof (vname), "description_%05d", ic); + out[vname] = "This is the blog title, yes blog title text DESCRIPTIOON - This is the blog title, yes blog title"; -long RecoCheckTaskDue( CVars in, CVars &out ){ - long ret = PHP_API_BAD_PARAM; - return ret; -} + snprintf(vname, sizeof (vname), "card_type_%05d", ic); + out[vname] = "BLOG"; -long RecoCheckBlog( CVars in, CVars &out ){ - long ret = PHP_API_BAD_PARAM; + snprintf(vname, sizeof (vname), "offer_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "blog_id_%05d", ic); + out[vname] = "0"; + + snprintf(vname, sizeof (vname), "card_icon_%05d", ic); + out[vname] = "icon1"; + + snprintf(vname, sizeof (vname), "banner_%05d", i); + out[vname] ="https://blog.wrenchboard.com/wp-content/uploads/2022/01/wrechboard-sample.jpg"; + + ret = PHP_API_OK; + + } catch (bad_parameter) { + out["status"] = "ERROR"; + } + logfmt(logINFO, "/RecoCheckBlog()"); return ret; }