Commit abeb80d6 authored by Richard Hughes's avatar Richard Hughes
Browse files

Sort the results by kudo for the shell sort provider

Ensure results are sorted before returning results to GNOME Shell, as typically
only 3 results are being shown. If this is not done we show the results in the
order they are parsed, which for AppStream are the application overrides and
distro-specific additions.

We sort by the kudo rather than the rating for two reasons; the first being that
only a few applications have been rated by end users, and the second that we get
the kudo information 'for free' meaning we don't have to set any additional
GsPluginRefine flags which would take longer to return to the shell.
parent 1d1c6acd
......@@ -88,6 +88,22 @@ cancel_current_search (GsShellSearchProvider *self)
* search_sort_by_kudo_cb:
static gint
search_sort_by_kudo_cb (gconstpointer a, gconstpointer b)
guint pa, pb;
pa = gs_app_get_kudos_percentage (GS_APP (a));
pb = gs_app_get_kudos_percentage (GS_APP (b));
if (pa < pb)
return 1;
else if (pa > pb)
return -1;
return 0;
static void
search_done_cb (GObject *source,
GAsyncResult *res,
......@@ -113,6 +129,9 @@ search_done_cb (GObject *source,
/* sort by kudos, as there is no ratings data by default */
list = g_list_sort (list, search_sort_by_kudo_cb);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
for (l = list; l != NULL; l = l->next) {
GsApp *app = GS_APP (l->data);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment