Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defines.hpp2
-rw-r--r--generator/generator_tests/ugc_test.cpp28
-rw-r--r--map/place_page_info.cpp4
-rw-r--r--partners_api/locals_api.cpp4
-rw-r--r--ugc/types.hpp3
5 files changed, 31 insertions, 10 deletions
diff --git a/defines.hpp b/defines.hpp
index ae229c8dc2..d05d8e21e8 100644
--- a/defines.hpp
+++ b/defines.hpp
@@ -110,4 +110,4 @@
#define BOOKING_EXCLUDED_FILE "booking_excluded.txt"
-auto constexpr kInvalidRatingValue = -1.0f;
+auto constexpr kInvalidRatingValue = 0.0f;
diff --git a/generator/generator_tests/ugc_test.cpp b/generator/generator_tests/ugc_test.cpp
index f03107c935..0030813c2b 100644
--- a/generator/generator_tests/ugc_test.cpp
+++ b/generator/generator_tests/ugc_test.cpp
@@ -16,7 +16,11 @@ std::string g_database(R"LLL(
CREATE TABLE ratings (key bigint, value blob);
INSERT INTO "ratings" VALUES(9826352,'{"osm_id":9826352,"total_rating":10.34,"based_on":721,"ratings":[{"key":"2","value":3.4},{"key":"2","value":6.0001}],"reviews":[{"id":7864532, "text":{"text":"The best service on the Earth","lang":"en"},"author":"Robert","rating":8.5,"date":1234567}]}');
INSERT INTO "ratings" VALUES(9826353,'{"osm_id":9826353,"total_rating":0.34,"based_on":1,"ratings":[{"key":"2","value":3.4},{"key":"3","value":6.0001},{"key":"6","value":0.0001}],"reviews":[{"id":78645323924,"text":{"text":"Изумительно!","lang":"ru"},"author":"Вася","rating":10,"date":1234569}]}');
- INSERT INTO "ratings" VALUES(9826354,'{"osm_id":9826354,"total_rating":-1.0,"based_on":1,"ratings":[{"key":"2","value":3.4},{"key":"3","value":6.0001},{"key":"6","value":0.0001}],"reviews":[{"id":78645323924,"text":{"text":"Изумительно!","lang":"ru"},"author":"Вася","rating":10,"date":1234569}]}');
+ INSERT INTO "ratings" VALUES(9826354,'{"osm_id":9826354,"total_rating":-1.0,"based_on":1,"ratings":[],"reviews":[{"id":78645323924,"text":{"text":"Изумительно!","lang":"ru"},"author":"Вася","rating":10,"date":1234569}]}');
+ INSERT INTO "ratings" VALUES(9826355,'{"osm_id":9826355,"total_rating":4.6,"based_on":1,"ratings":[{"key":"2","value":3.4},{"key":"3","value":6.0001},{"key":"6","value":0.0001}],"reviews":[]}');
+ INSERT INTO "ratings" VALUES(9826356,'{"osm_id":9826356,"total_rating":-1.0,"based_on":1,"ratings":[{"key":"2","value":3.4},{"key":"3","value":6.0001},{"key":"6","value":0.0001}],"reviews":[]}');
+ INSERT INTO "ratings" VALUES(9826357,'{"osm_id":9826357,"total_rating":3.7,"based_on":0,"ratings":[{"key":"2","value":3.4},{"key":"3","value":6.0001},{"key":"6","value":0.0001}],"reviews":[]}');
+ INSERT INTO "ratings" VALUES(9826358,'{"osm_id":9826358,"total_rating":3.8,"based_on":1,"ratings":[],"reviews":[]}');
CREATE INDEX key_index ON ratings (key);
COMMIT;
)LLL");
@@ -56,7 +60,25 @@ UNIT_TEST(UGC_TranslateRatingTest)
UNIT_TEST(UGC_TranslateEmptyUgcTest)
{
- auto const ugc = GetUgcForId(9826354);
- TEST(ugc.IsEmpty(), ());
+ {
+ auto const ugc = GetUgcForId(9826354);
+ TEST(!ugc.IsEmpty(), ());
+ }
+ {
+ auto const ugc = GetUgcForId(9826355);
+ TEST(!ugc.IsEmpty(), ());
+ }
+ {
+ auto const ugc = GetUgcForId(9826356);
+ TEST(ugc.IsEmpty(), ());
+ }
+ {
+ auto const ugc = GetUgcForId(9826357);
+ TEST(ugc.IsEmpty(), ());
+ }
+ {
+ auto const ugc = GetUgcForId(9826358);
+ TEST(ugc.IsEmpty(), ());
+ }
}
} // namespace
diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp
index 453b6f671b..33e834d4ca 100644
--- a/map/place_page_info.cpp
+++ b/map/place_page_info.cpp
@@ -357,7 +357,7 @@ Impress GetImpress(float const rawRating)
CHECK_LESS_OR_EQUAL(rawRating, kTopRatingBound, ());
CHECK_GREATER_OR_EQUAL(rawRating, kIncorrectRating, ());
- if (rawRating <= 0.0f)
+ if (rawRating == kIncorrectRating)
return Impress::None;
if (rawRating < 0.2f * kTopRatingBound)
return Impress::Horrible;
@@ -376,7 +376,7 @@ std::string GetRatingFormatted(float const rawRating)
CHECK_LESS_OR_EQUAL(rawRating, kTopRatingBound, ());
CHECK_GREATER_OR_EQUAL(rawRating, kIncorrectRating, ());
- if (rawRating <= 0.0f)
+ if (rawRating == kIncorrectRating)
return kEmptyRatingSymbol;
std::ostringstream oss;
diff --git a/partners_api/locals_api.cpp b/partners_api/locals_api.cpp
index 0733b0052e..fd06b22dbd 100644
--- a/partners_api/locals_api.cpp
+++ b/partners_api/locals_api.cpp
@@ -59,9 +59,7 @@ void ParseLocals(std::string const & src, std::vector<LocalExpert> & locals,
FromJSONObject(item, "i_will_show_you", local.m_offerDescription);
// Rescale rating to (0.0; 10.0] range. Rating 0.0 is invalid.
- if (local.m_rating == 0.0)
- local.m_rating = kInvalidRatingValue;
- else
+ if (local.m_rating != kInvalidRatingValue)
local.m_rating *= 2.0;
locals.push_back(std::move(local));
diff --git a/ugc/types.hpp b/ugc/types.hpp
index f1948d5d61..327b174280 100644
--- a/ugc/types.hpp
+++ b/ugc/types.hpp
@@ -337,7 +337,8 @@ struct UGC
bool IsEmpty() const
{
- return !((!m_ratings.empty() || !m_reviews.empty()) && m_totalRating >= 0 && m_basedOn > 0);
+ return m_reviews.empty() &&
+ (m_ratings.empty() || m_totalRating <= kInvalidRatingValue || m_basedOn == 0);
}
Ratings m_ratings;