[gnome-software] Ensure reviews are shown in the correct order
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Ensure reviews are shown in the correct order
- Date: Thu, 23 Jun 2016 08:53:08 +0000 (UTC)
commit 3f7482ead1582de6f8b24e798b50ae475dbeee79
Author: Richard Hughes <richard hughsie com>
Date: Thu Jun 23 09:52:30 2016 +0100
Ensure reviews are shown in the correct order
src/gs-plugin-loader.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index f22cc81..b4f56a9 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -275,6 +275,18 @@ gs_plugin_loader_run_adopt (GsPluginLoader *plugin_loader, GsAppList *list)
}
}
+static gint
+gs_plugin_loader_review_score_sort_cb (gconstpointer a, gconstpointer b)
+{
+ GsReview *ra = *((GsReview **) a);
+ GsReview *rb = *((GsReview **) b);
+ if (gs_review_get_score (ra) < gs_review_get_score (rb))
+ return 1;
+ if (gs_review_get_score (ra) > gs_review_get_score (rb))
+ return -1;
+ return 0;
+}
+
/**
* gs_plugin_loader_run_refine_internal:
**/
@@ -383,6 +395,17 @@ gs_plugin_loader_run_refine_internal (GsPluginLoader *plugin_loader,
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
}
+ /* ensure these are sorted by score */
+ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) > 0) {
+ GPtrArray *reviews;
+ for (i = 0; i < gs_app_list_length (list); i++) {
+ app = gs_app_list_index (list, i);
+ reviews = gs_app_get_reviews (app);
+ g_ptr_array_sort (reviews,
+ gs_plugin_loader_review_score_sort_cb);
+ }
+ }
+
/* refine addons one layer deep */
if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS) > 0) {
g_autoptr(GsAppList) addons_list = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]