From f423891f5695cf6a3670f4c5771741620cff9a47 Mon Sep 17 00:00:00 2001 From: Sergey Magidovich Date: Wed, 25 May 2016 17:08:43 +0300 Subject: [PATCH] Add DropUserStats. Code review. --- editor/editor_tests/user_stats_test.cpp | 2 +- editor/user_stats.cpp | 2 +- map/framework.cpp | 6 +++--- map/framework.hpp | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/editor/editor_tests/user_stats_test.cpp b/editor/editor_tests/user_stats_test.cpp index aae2ecbf46..db68bb7712 100644 --- a/editor/editor_tests/user_stats_test.cpp +++ b/editor/editor_tests/user_stats_test.cpp @@ -14,7 +14,7 @@ UNIT_TEST(UserStats_Smoke) TEST(userStats.IsChangesCountInitialized(), ()); TEST(userStats.IsRankInitialized(), ()); TEST_EQUAL(userStats.GetChangesCount(), 2, ()); - TEST_GREATER_OR_EQUAL(userStats.GetRank(), 5762, ()); + TEST_GREATER_OR_EQUAL(userStats.GetRank(), 5800, ()); } } // namespace } // namespace editor diff --git a/editor/user_stats.cpp b/editor/user_stats.cpp index dbfe4640d0..76788e0e75 100644 --- a/editor/user_stats.cpp +++ b/editor/user_stats.cpp @@ -47,7 +47,7 @@ bool UserStats::Update() if (request.error_code() != 200) { - LOG(LWARNING, ("Server return", request.error_code(), "for url", url)); + LOG(LWARNING, ("Server returned", request.error_code(), "for url", url)); return false; } diff --git a/map/framework.cpp b/map/framework.cpp index 4632e7a86f..1c9896b884 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2885,9 +2885,9 @@ bool Framework::RollBackChanges(FeatureID const & fid) bool Framework::UpdateUserStats(string const & userName) { - auto newUserStats = make_unique(userName); - if (!newUserStats->GetUpdateStatus()) + auto userStats = make_unique(userName); + if (!userStats->GetUpdateStatus()) return false; - m_userStats.reset(newUserStats.release()); + m_userStats = move(userStats); return true; } diff --git a/map/framework.hpp b/map/framework.hpp index cfbedf1130..b804ac06d8 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -677,9 +677,10 @@ public: //@{ //User statistics. editor::UserStats const * GetUserStats() const { return m_userStats.get(); } - /// Synchronously request the server and updates users stats. + /// Sends a synchronous request to the server and updates user's stats. /// @returns true on success. bool UpdateUserStats(string const & userName); + void DropUserStats() { m_userStats = nullptr; } private: unique_ptr m_userStats;