[gnome-software] Use the review rating count for total reviews



commit c68ad3169bdba8792515d32a24867c00c0546480
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Feb 10 12:17:32 2016 +1300

    Use the review rating count for total reviews
    
    Use the review ratings values to calculate total number of reviews. There may be
    more reviews than is practical to download.

 src/gs-shell-details.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index db72b02..52c6188 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -580,6 +580,7 @@ gs_shell_details_refresh_all (GsShellDetails *self)
 {
        GPtrArray *history;
        GArray *review_ratings;
+       gint n_reviews;
        GdkPixbuf *pixbuf = NULL;
        GList *addons;
        GtkWidget *widget;
@@ -745,10 +746,20 @@ gs_shell_details_refresh_all (GsShellDetails *self)
                } else {
                        gtk_widget_set_visible (self->histogram, FALSE);
                }
-               if (gs_app_get_reviews (self->app) != NULL) {
+               n_reviews = 0;
+               if (review_ratings != NULL || gs_app_get_reviews (self->app) != NULL) {
+                       if (review_ratings != NULL) {
+                               guint i;
+                               for (i = 0; i < review_ratings->len; i++)
+                                       n_reviews += g_array_index (review_ratings, gint, i);
+                       } else  {
+                               n_reviews = gs_app_get_reviews (self->app)->len;
+                       }
+               }
+               if (n_reviews > 0) {
                        g_autofree gchar *text = NULL;
                        gtk_widget_set_visible (self->label_review_count, TRUE);
-                       text = g_strdup_printf ("(%u)", gs_app_get_reviews (self->app)->len);
+                       text = g_strdup_printf ("(%u)", n_reviews);
                        gtk_label_set_text (GTK_LABEL (self->label_review_count), text);
                } else {
                        gtk_widget_set_visible (self->label_review_count, FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]