Merge pull request #5810 from milchakov/ads_hot_fix_master

Ads hot fix master
This commit is contained in:
mpimenov 2017-04-12 12:25:30 +04:00 committed by GitHub
commit 8f6af289af
6 changed files with 26 additions and 109 deletions

View file

@ -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

View file

@ -8,8 +8,6 @@ namespace ads
class Facebook : public Container
{
public:
Facebook();
// ContainerBase overrides:
std::string GetBannerIdForOtherTypes() const override;
};

View file

@ -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"}));

View file

@ -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;

View file

@ -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"}));

View file

@ -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"},