diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2018-01-18 13:50:15 +0300 |
---|---|---|
committer | Ilya Grechuhin <i.grechuhin@gmail.com> | 2018-01-22 11:13:02 +0300 |
commit | cf21430055d8162970748c62d9860ded1a9419b1 (patch) | |
tree | 1a4e518324248c585f64be59ad01568050a2220f /indexer/ftypes_sponsored.cpp | |
parent | 70a5d621be45afcdaf362332e705855339fbc6ee (diff) |
Added new partners system
Diffstat (limited to 'indexer/ftypes_sponsored.cpp')
-rw-r--r-- | indexer/ftypes_sponsored.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/indexer/ftypes_sponsored.cpp b/indexer/ftypes_sponsored.cpp index 5ac582c696..07f2eb2cb4 100644 --- a/indexer/ftypes_sponsored.cpp +++ b/indexer/ftypes_sponsored.cpp @@ -1,6 +1,14 @@ #include "indexer/ftypes_sponsored.hpp" #include "indexer/classificator.hpp" +#include "indexer/feature.hpp" +#include "indexer/feature_data.hpp" + +#include "base/string_utils.hpp" + +#include "private.h" + +#include <algorithm> namespace ftypes { @@ -8,4 +16,24 @@ BaseSponsoredChecker::BaseSponsoredChecker(std::string const & sponsoredType) { m_types.push_back(classif().GetTypeByPath({"sponsored", sponsoredType})); } + +SponsoredPartnerChecker::SponsoredPartnerChecker() +{ + Classificator const & c = classif(); + for (size_t i = 1; i <= MAX_PARTNERS_COUNT; i++) + m_types.push_back(c.GetTypeByPath({"sponsored", "partner" + strings::to_string(i)})); +} + +int SponsoredPartnerChecker::GetPartnerIndex(FeatureType const & ft) const +{ + auto const types = feature::TypesHolder(ft); + int index = 0; + for (auto t : m_types) + { + if (std::find(types.begin(), types.end(), PrepareToMatch(t, 2 /* level */)) != types.end()) + return index; + index++; + } + return -1; +} } // namespace ftypes |