diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2018-11-08 19:26:03 +0300 |
---|---|---|
committer | Tatiana Yan <tatiana.kondakova@gmail.com> | 2018-11-14 13:39:35 +0300 |
commit | 67d6885283924d6c13866fcacd2d55ae3aba6723 (patch) | |
tree | 049d84e2de92da71e69e5cb4a2b341c2b16028ef /metrics | |
parent | 052e75adda90696cf91eb511c32adda6aaf36137 (diff) |
[notifications] ugc rate notification business logic
Diffstat (limited to 'metrics')
-rw-r--r-- | metrics/eye.cpp | 46 | ||||
-rw-r--r-- | metrics/eye.hpp | 17 | ||||
-rw-r--r-- | metrics/eye_info.hpp | 8 |
3 files changed, 35 insertions, 36 deletions
diff --git a/metrics/eye.cpp b/metrics/eye.cpp index 173bf29b03..a889b44ff8 100644 --- a/metrics/eye.cpp +++ b/metrics/eye.cpp @@ -10,7 +10,6 @@ #include "base/logging.hpp" #include <algorithm> -#include <chrono> #include <memory> #include <utility> #include <vector> @@ -105,6 +104,12 @@ void Eye::UnsubscribeAll() m_subscribers.clear(); } +// static +std::chrono::hours const & Eye::GetMapObjectEventsExpirePeriod() +{ + return kMapObjectEventsExpirePeriod; +} + void Eye::TrimExpired() { GetPlatform().RunTask(Platform::Thread::File, [this] @@ -417,56 +422,47 @@ void Eye::Event::LayerShown(Layer::Type type) } // static -void Eye::Event::PlacePageOpened(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos) +void Eye::Event::PlacePageOpened(MapObject const & mapObject, m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [bestType, pos, readableName, userPos] + GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent({bestType, pos, readableName}, MapObject::Event::Type::Open, userPos); + Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::Open, userPos); }); } // static -void Eye::Event::UgcEditorOpened(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos) +void Eye::Event::UgcEditorOpened(MapObject const & mapObject, m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [bestType, pos, readableName, userPos] + GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent({bestType, pos, readableName}, MapObject::Event::Type::UgcEditorOpened, - userPos); + Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::UgcEditorOpened, userPos); }); } // static -void Eye::Event::UgcSaved(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos) +void Eye::Event::UgcSaved(MapObject const & mapObject, m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [bestType, pos, readableName, userPos] + GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent({bestType, pos, readableName}, MapObject::Event::Type::UgcSaved, - userPos); + Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::UgcSaved, userPos); }); } // static -void Eye::Event::AddToBookmarkClicked(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos) +void Eye::Event::AddToBookmarkClicked(MapObject const & mapObject, m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [bestType, pos, readableName, userPos] + GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent({bestType, pos, readableName}, MapObject::Event::Type::AddToBookmark, - userPos); + Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::AddToBookmark, userPos); }); } // static -void Eye::Event::RouteCreatedToObject(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos) +void Eye::Event::RouteCreatedToObject(MapObject const & mapObject, m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [bestType, pos, readableName, userPos] + GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent({bestType, pos, readableName}, MapObject::Event::Type::RouteToCreated, - userPos); + Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::RouteToCreated, userPos); }); } } // namespace eye diff --git a/metrics/eye.hpp b/metrics/eye.hpp index 1ff68a1bd9..fe22baf7bd 100644 --- a/metrics/eye.hpp +++ b/metrics/eye.hpp @@ -5,6 +5,7 @@ #include "base/atomic_shared_ptr.hpp" #include "base/macros.hpp" +#include <chrono> #include <string> #include <vector> @@ -44,16 +45,11 @@ public: static void DiscoveryShown(); static void DiscoveryItemClicked(Discovery::Event event); static void LayerShown(Layer::Type type); - static void PlacePageOpened(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos); - static void UgcEditorOpened(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos); - static void UgcSaved(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos); - static void AddToBookmarkClicked(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos); - static void RouteCreatedToObject(std::string const & bestType, m2::PointD const & pos, - std::string const & readableName, m2::PointD const & userPos); + static void PlacePageOpened(MapObject const & mapObject, m2::PointD const & userPos); + static void UgcEditorOpened(MapObject const & mapObject, m2::PointD const & userPos); + static void UgcSaved(MapObject const & mapObject, m2::PointD const & userPos); + static void AddToBookmarkClicked(MapObject const & mapObject, m2::PointD const & userPos); + static void RouteCreatedToObject(MapObject const & mapObject, m2::PointD const & userPos); }; static Eye & Instance(); @@ -64,6 +60,7 @@ public: void Subscribe(Subscriber * subscriber); void UnsubscribeAll(); + static std::chrono::hours const & GetMapObjectEventsExpirePeriod(); void TrimExpired(); private: diff --git a/metrics/eye_info.hpp b/metrics/eye_info.hpp index 89613ba0aa..23142d6fee 100644 --- a/metrics/eye_info.hpp +++ b/metrics/eye_info.hpp @@ -219,6 +219,10 @@ public: MercatorBounds::ClampX(pos.x + 1e-7), MercatorBounds::ClampY(pos.y + 1e-7)}; } + std::vector<std::string> const & GetMwmNames() const { return m_mwmNames; } + + void SetMwmNames(std::vector<std::string> const & ids) { m_mwmNames = ids; } + std::string const & GetReadableName() const { return m_readableName; } void SetReadableName(std::string const & readableName) { m_readableName = readableName; } @@ -230,11 +234,13 @@ public: m2::RectD GetLimitRect() const { return m_limitRect; } DECLARE_VISITOR(visitor(m_bestType, "type"), visitor(m_pos, "pos"), - visitor(m_readableName, "name"), visitor(m_events, "events")); + visitor(m_mwmNames, "mwm_names"), visitor(m_readableName, "name"), + visitor(m_events, "events")); private: std::string m_bestType; m2::PointD m_pos; + std::vector<std::string> m_mwmNames; std::string m_readableName; // Mutable because of interface of the m4::Tree provides constant references in ForEach methods, // but we need to add events into existing objects to avoid some overhead (copy + change + |