[gnome-software/wip/rancell/ubuntu-ratings] Convert ratings correctly
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/ubuntu-ratings] Convert ratings correctly
- Date: Thu, 12 Nov 2015 02:30:09 +0000 (UTC)
commit 13bfa60474678edbb7eaa8a59eb6aa4eb1c46704
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 12 15:13:45 2015 +1300
Convert ratings correctly
src/plugins/gs-plugin-ubuntu-reviews.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index cee24c4..8a75284 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include <math.h>
#include <libsoup/soup.h>
#include <sqlite3.h>
#include <json-glib/json-glib.h>
@@ -225,14 +226,15 @@ gs_plugin_ubuntu_review_stats_download (GsPlugin *plugin, GError **error)
json_reader_read_element (reader, i);
if (json_reader_is_object (reader)) {
const gchar *package_name;
- gdouble rating;
+ gint rating;
json_reader_read_member (reader, "package_name");
package_name = json_reader_get_string_value (reader);
json_reader_end_member (reader);
json_reader_read_member (reader, "ratings_average");
- rating = g_ascii_strtod (json_reader_get_string_value (reader), NULL);
+ /* convert star ratings *->10, **->30, ***->50, ****->70, *****->90 */
+ rating = round (20 * g_ascii_strtod (json_reader_get_string_value (reader), NULL) -
10);
json_reader_end_member (reader);
}
json_reader_end_element (reader);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]