From 4daf1d06931e8ece60baa54b553679c1965f632f Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Tue, 11 Apr 2017 15:42:05 +0300 Subject: [PATCH] ads hot fix --- partners_api/facebook_ads.cpp | 95 +------------------ partners_api/facebook_ads.hpp | 2 - .../partners_api_tests/ads_engine_tests.cpp | 18 ++-- .../partners_api_tests/facebook_tests.cpp | 10 +- partners_api/partners_api_tests/rb_tests.cpp | 5 + partners_api/rb_ads.cpp | 5 +- 6 files changed, 26 insertions(+), 109 deletions(-) diff --git a/partners_api/facebook_ads.cpp b/partners_api/facebook_ads.cpp index ebf026bef9..07b19d60f9 100644 --- a/partners_api/facebook_ads.cpp +++ b/partners_api/facebook_ads.cpp @@ -3,105 +3,16 @@ namespace { #if defined(OMIM_OS_IPHONE) - auto const kFoodPlacementId = "185237551520383_1425355070841952"; - auto const kShopsPlacementId = "185237551520383_1425355647508561"; - auto const kCityTransportPlacementId = "185237551520383_1425356124175180"; - auto const kGlobalTransportPlacementId = "185237551520383_1425356400841819"; - auto const kHotelsPlacementId = "185237551520383_1425356560841803"; - auto const kSightsPlacementId = "185237551520383_1425356720841787"; - auto const kLargeToponymsPlacementId = "185237551520383_1425356987508427"; - auto const kHealthPlacementId = "185237551520383_1425357194175073"; - auto const kFinancialPlacementId = "185237551520383_1425358064174986"; - auto const kEntertainmentPlacementId = "185237551520383_1425358274174965"; - auto const kBuildingPlacementId = "185237551520383_1425358410841618"; - auto const kBannerIdForOtherTypes = "185237551520383_1425363454174447"; + auto const kSingleBannerIdForAllTypes = "185237551520383_1450324925011633"; #else - auto const kFoodPlacementId = "185237551520383_1384650164912443"; - auto const kShopsPlacementId = "185237551520383_1384650804912379"; - auto const kCityTransportPlacementId = "185237551520383_1384651074912352"; - auto const kGlobalTransportPlacementId = "185237551520383_1387632484614211"; - auto const kHotelsPlacementId = "185237551520383_1384651324912327"; - auto const kSightsPlacementId = "185237551520383_1384651734912286"; - auto const kLargeToponymsPlacementId = "185237551520383_1384652164912243"; - auto const kHealthPlacementId = "185237551520383_1384652351578891"; - auto const kFinancialPlacementId = "185237551520383_1384652658245527"; - auto const kEntertainmentPlacementId = "185237551520383_1384653001578826"; - auto const kBuildingPlacementId = "185237551520383_1419317661445693"; - auto const kBannerIdForOtherTypes = "185237551520383_1384653421578784"; + auto const kSingleBannerIdForAllTypes = "185237551520383_1450325641678228"; #endif } // namespace namespace ads { -Facebook::Facebook() -{ - AppendEntry({{"amenity", "cafe"}, - {"amenity", "fast_food"}, - {"amenity", "restaurant"}, - {"amenity", "bar"}, - {"amenity", "pub"}}, - kFoodPlacementId); - - AppendEntry({{"shop"}, - {"amenity", "marketplace"}}, - kShopsPlacementId); - - AppendEntry({{"aerialway"}, - {"highway", "bus_stop"}, - {"highway", "speed_camera"}, - {"public_transport"}}, - kCityTransportPlacementId); - - AppendEntry({{"aeroway"}, - {"railway"}, - {"man_made", "pier"}}, - kGlobalTransportPlacementId); - - AppendEntry({{"tourism", "hotel"}, - {"tourism", "hostel"}, - {"tourism", "motel"}, - {"tourism", "apartment"}, - {"tourism", "resort"}}, - kHotelsPlacementId); - - AppendEntry({{"tourism", "chalet"}, - {"tourism", "zoo"}, - {"tourism", "artwork"}, - {"tourism", "information"}, - {"tourism", "attraction"}, - {"tourism", "viewpoint"}, - {"tourism", "museum"}, - {"amenity", "fountain"}, - {"amenity", "townhall"}, - {"historic"}}, - kSightsPlacementId); - - AppendEntry({{"place"}}, kLargeToponymsPlacementId); - - AppendEntry({{"amenity", "dentist"}, - {"amenity", "doctors"}, - {"amenity", "clinic"}, - {"amenity", "hospital"}, - {"amenity", "pharmacy"}, - {"amenity", "veterinary"}}, - kHealthPlacementId); - - AppendEntry({{"amenity", "bank"}, {"amenity", "atm"}}, kFinancialPlacementId); - - AppendEntry({{"amenity", "cinema"}, - {"amenity", "brothel"}, - {"amenity", "casino"}, - {"amenity", "nightclub"}, - {"amenity", "theatre"}, - {"boundary", "national_park"}, - {"leisure"}}, - kEntertainmentPlacementId); - - AppendEntry({{"building"}}, kBuildingPlacementId); -} - std::string Facebook::GetBannerIdForOtherTypes() const { - return kBannerIdForOtherTypes; + return kSingleBannerIdForAllTypes; } } // namespace ads diff --git a/partners_api/facebook_ads.hpp b/partners_api/facebook_ads.hpp index 3643710b04..eea41497b4 100644 --- a/partners_api/facebook_ads.hpp +++ b/partners_api/facebook_ads.hpp @@ -8,8 +8,6 @@ namespace ads class Facebook : public Container { public: - Facebook(); - // ContainerBase overrides: std::string GetBannerIdForOtherTypes() const override; }; diff --git a/partners_api/partners_api_tests/ads_engine_tests.cpp b/partners_api/partners_api_tests/ads_engine_tests.cpp index afa16b802c..26b102307a 100644 --- a/partners_api/partners_api_tests/ads_engine_tests.cpp +++ b/partners_api/partners_api_tests/ads_engine_tests.cpp @@ -31,19 +31,20 @@ UNIT_TEST(AdsEngine_Smoke) classificator::Load(); Classificator const & c = classif(); ads::Engine engine; + ads::Facebook facebook; { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"amenity", "dentist"})); TEST(engine.HasBanner(holder, {"Ukraine"}), ()); auto result = engine.GetBanners(holder, {"Ukraine"}); CheckCountAndTypes(result); - CheckIds(result, {"7", "185237551520383_1384652351578891"}); + CheckIds(result, {"7", facebook.GetBannerIdForOtherTypes()}); holder.Add(c.GetTypeByPath({"amenity", "pub"})); TEST(engine.HasBanner(holder, {"Ukraine"}), ()); result = engine.GetBanners(holder, {"Ukraine"}); CheckCountAndTypes(result); - CheckIds(result, {"7", "185237551520383_1384652351578891"}); + CheckIds(result, {"7", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; @@ -51,7 +52,7 @@ UNIT_TEST(AdsEngine_Smoke) TEST(engine.HasBanner(holder, {"Moldova"}), ()); auto result = engine.GetBanners(holder, {"Moldova"}); CheckCountAndTypes(result); - CheckIds(result, {"5", "185237551520383_1384651734912286"}); + CheckIds(result, {"5", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; @@ -59,7 +60,7 @@ UNIT_TEST(AdsEngine_Smoke) TEST(engine.HasBanner(holder, {"Russian Federation"}), ()); auto result = engine.GetBanners(holder, {"Russian Federation"}); CheckCountAndTypes(result); - CheckIds(result, {"2", "185237551520383_1384650804912379"}); + CheckIds(result, {"2", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; @@ -67,7 +68,7 @@ UNIT_TEST(AdsEngine_Smoke) TEST(engine.HasBanner(holder, {"Belarus"}), ()); auto result = engine.GetBanners(holder, {"Belarus"}); CheckCountAndTypes(result); - CheckIds(result, {"8", "185237551520383_1384652658245527"}); + CheckIds(result, {"8", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; @@ -75,7 +76,7 @@ UNIT_TEST(AdsEngine_Smoke) TEST(engine.HasBanner(holder, {"Spain", "Ukraine"}), ()); auto result = engine.GetBanners(holder, {"Spain", "Ukraine"}); CheckCountAndTypes(result); - CheckIds(result, {"1", "185237551520383_1384650164912443"}); + CheckIds(result, {"1", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; @@ -83,18 +84,17 @@ UNIT_TEST(AdsEngine_Smoke) TEST(engine.HasBanner(holder, {"Ukraine", "Spain"}), ()); auto result = engine.GetBanners(holder, {"Ukraine", "Spain"}); CheckCountAndTypes(result); - CheckIds(result, {"1", "185237551520383_1384650164912443"}); + CheckIds(result, {"1", facebook.GetBannerIdForOtherTypes()}); } { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"amenity", "pub"})); TEST(engine.HasBanner(holder, {"Spain"}), ()); auto result = engine.GetBanners(holder, {"Spain"}); - CheckIds(result, {"185237551520383_1384650164912443"}); + CheckIds(result, {facebook.GetBannerIdForOtherTypes()}); TEST_EQUAL(result[0].m_type, ads::Banner::Type::Facebook, ()); } ads::Rb rb; - ads::Facebook facebook; { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"amenity", "toilets"})); diff --git a/partners_api/partners_api_tests/facebook_tests.cpp b/partners_api/partners_api_tests/facebook_tests.cpp index 9acc685d13..1760f5a82d 100644 --- a/partners_api/partners_api_tests/facebook_tests.cpp +++ b/partners_api/partners_api_tests/facebook_tests.cpp @@ -16,24 +16,24 @@ UNIT_TEST(Facebook_GetBanner) { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"amenity", "dentist"})); - TEST_EQUAL(facebook.GetBannerId(holder, "Brazil"), "185237551520383_1384652351578891", ()); + TEST_EQUAL(facebook.GetBannerId(holder, "Brazil"), facebook.GetBannerIdForOtherTypes(), ()); holder.Add(c.GetTypeByPath({"amenity", "pub"})); - TEST_EQUAL(facebook.GetBannerId(holder, "Cuba"), "185237551520383_1384652351578891", ()); + TEST_EQUAL(facebook.GetBannerId(holder, "Cuba"), facebook.GetBannerIdForOtherTypes(), ()); } { feature::TypesHolder holder; holder.Add(c.GetTypeByPath({"amenity", "restaurant"})); - TEST_EQUAL(facebook.GetBannerId(holder, "Any country"), "185237551520383_1384650164912443", ()); + TEST_EQUAL(facebook.GetBannerId(holder, "Any country"), facebook.GetBannerIdForOtherTypes(), ()); } { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"tourism", "information", "map"})); - TEST_EQUAL(facebook.GetBannerId(holder, "Russia"), "185237551520383_1384651734912286", ()); + TEST_EQUAL(facebook.GetBannerId(holder, "Russia"), facebook.GetBannerIdForOtherTypes(), ()); } { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"shop", "ticket"})); - TEST_EQUAL(facebook.GetBannerId(holder, "USA"), "185237551520383_1384650804912379", ()); + TEST_EQUAL(facebook.GetBannerId(holder, "USA"), facebook.GetBannerIdForOtherTypes(), ()); } { feature::TypesHolder holder; diff --git a/partners_api/partners_api_tests/rb_tests.cpp b/partners_api/partners_api_tests/rb_tests.cpp index 80957473d0..e1ddd7005f 100644 --- a/partners_api/partners_api_tests/rb_tests.cpp +++ b/partners_api/partners_api_tests/rb_tests.cpp @@ -45,6 +45,11 @@ UNIT_TEST(Rb_GetBanner) holder.Assign(c.GetTypeByPath({"amenity", "atm"})); TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "8", ()); } + { + feature::TypesHolder holder; + holder.Assign(c.GetTypeByPath({"amenity", "bureau_de_change"})); + TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "8", ()); + } { feature::TypesHolder holder; holder.Assign(c.GetTypeByPath({"amenity", "atm"})); diff --git a/partners_api/rb_ads.cpp b/partners_api/rb_ads.cpp index 23a7d2d10c..9d6b49948a 100644 --- a/partners_api/rb_ads.cpp +++ b/partners_api/rb_ads.cpp @@ -86,7 +86,10 @@ Rb::Rb() {"amenity", "veterinary"}}, kHealthPlacementId); - AppendEntry({{"amenity", "bank"}, {"amenity", "atm"}}, kFinancialPlacementId); + AppendEntry({{"amenity", "bank"}, + {"amenity", "atm"}, + {"amenity", "bureau_de_change"}}, + kFinancialPlacementId); AppendEntry({{"amenity", "cinema"}, {"amenity", "brothel"},