From 043d9201b415ef17f839580a7adc39f3e5e67b19 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 24 Feb 2022 13:04:21 +0100 Subject: [PATCH 1/6] gs-plugin-loader: Filter out non-desktop apps from get-recent action There can be also runtimes, extensions and so on recently released, but these should not be shown in the 'New & Updated' section. --- lib/gs-plugin-loader.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c index 6c65e41fa..b40c99ff2 100644 --- a/lib/gs-plugin-loader.c +++ b/lib/gs-plugin-loader.c @@ -1121,6 +1121,12 @@ gs_plugin_loader_app_is_non_compulsory (GsApp *app, gpointer user_data) return !gs_app_has_quirk (app, GS_APP_QUIRK_COMPULSORY); } +static gboolean +gs_plugin_loader_app_is_desktop (GsApp *app, gpointer user_data) +{ + return gs_app_get_kind (app) == AS_COMPONENT_KIND_DESKTOP_APP; +} + static gboolean gs_plugin_loader_get_app_is_compatible (GsApp *app, gpointer user_data) { @@ -3364,6 +3370,7 @@ gs_plugin_loader_process_thread_cb (GTask *task, break; case GS_PLUGIN_ACTION_GET_RECENT: gs_app_list_filter (list, gs_plugin_loader_app_is_non_compulsory, NULL); + gs_app_list_filter (list, gs_plugin_loader_app_is_desktop, NULL); gs_app_list_filter (list, gs_plugin_loader_app_is_valid_filter, helper); gs_app_list_filter (list, gs_plugin_loader_filter_qt_for_gtk, NULL); gs_app_list_filter (list, gs_plugin_loader_get_app_is_compatible, plugin_loader); -- GitLab From 5e93387c532db18403d3fec369627fd2aeb071f7 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 25 Feb 2022 12:19:35 +0100 Subject: [PATCH 2/6] gs-plugin-loader: Do preliminary filtering when getting recent apps The list can contain duplicates and other non-applicable apps, which can be recognized also without a full app refine. This way the list is truncated with a better set, where are the most apps relevant for the result. --- lib/gs-plugin-loader.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c index b40c99ff2..d50ba52dc 100644 --- a/lib/gs-plugin-loader.c +++ b/lib/gs-plugin-loader.c @@ -3229,6 +3229,13 @@ gs_plugin_loader_process_thread_cb (GTask *task, } } + if (action == GS_PLUGIN_ACTION_GET_RECENT) { + /* Preliminary filter recent apps, to have truncated a meaningful list */ + gs_app_list_filter_duplicates (list, GS_APP_LIST_FILTER_FLAG_KEY_ID); + gs_app_list_filter (list, gs_plugin_loader_app_is_non_compulsory, NULL); + gs_app_list_filter (list, gs_plugin_loader_app_is_desktop, NULL); + } + /* filter to reduce to a sane set */ gs_plugin_loader_job_sorted_truncation (helper); -- GitLab From b7355799ff13e244f6b9e24a9210f7b054a8451c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 25 Feb 2022 12:17:33 +0100 Subject: [PATCH 3/6] gs-appstream: Set also release date in gs_appstream_add_recent() It can be used to sort the applications by the release date, thus provide it without a need to a full app refine. --- lib/gs-appstream.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c index 0334447c4..861d1d6dc 100644 --- a/lib/gs-appstream.c +++ b/lib/gs-appstream.c @@ -1619,8 +1619,13 @@ gs_appstream_add_recent (GsPlugin *plugin, for (guint i = 0; i < array->len; i++) { XbNode *component = g_ptr_array_index (array, i); g_autoptr(GsApp) app = gs_appstream_create_app (plugin, silo, component, error); + guint64 timestamp; if (app == NULL) return FALSE; + /* set the release date */ + timestamp = component_get_release_timestamp (component); + if (timestamp != G_MAXUINT64) + gs_app_set_release_date (app, timestamp); gs_app_list_add (list, app); } return TRUE; -- GitLab From d44aa380ade47be03e1f14fe07540cce4d1ff617 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 25 Feb 2022 12:23:20 +0100 Subject: [PATCH 4/6] gs-appstream: Use the passed-in 'age' argument ...rather than hard-code the recent limit to 30 days. --- lib/gs-appstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c index 861d1d6dc..919349d9f 100644 --- a/lib/gs-appstream.c +++ b/lib/gs-appstream.c @@ -1606,7 +1606,7 @@ gs_appstream_add_recent (GsPlugin *plugin, /* use predicate conditions to the max */ xpath = g_strdup_printf ("components/component/releases/" "release[@timestamp>%" G_GUINT64_FORMAT "]/../..", - now - (30 * 24 * 60 * 60)); + now - age); array = xb_silo_query (silo, xpath, 0, &error_local); if (array == NULL) { if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) -- GitLab From 2c5403e02584889c2b9b179e97a41fe902ba98b3 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 24 Feb 2022 13:06:07 +0100 Subject: [PATCH 5/6] gs-overview-page: Sort recent applications by their release date Thus the list shows the most recently updated applications first. Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1630 --- src/gs-overview-page.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c index 50e2e2cfb..36463030a 100644 --- a/src/gs-overview-page.c +++ b/src/gs-overview-page.c @@ -169,6 +169,18 @@ out: gs_overview_page_decrement_action_cnt (self); } +static gint +gs_overview_page_sort_recent_cb (GsApp *app1, + GsApp *app2, + gpointer user_data) +{ + if (gs_app_get_release_date (app1) < gs_app_get_release_date (app2)) + return 1; + if (gs_app_get_release_date (app1) == gs_app_get_release_date (app2)) + return g_strcmp0 (gs_app_get_name (app1), gs_app_get_name (app2)); + return -1; +} + static void gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -198,7 +210,7 @@ gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpoin goto out; } - gs_app_list_randomize (list); + gs_app_list_sort (list, gs_overview_page_sort_recent_cb, NULL); gs_widget_remove_all (self->box_recent, (GsRemoveFunc) gtk_flow_box_remove); @@ -515,12 +527,14 @@ gs_overview_page_load (GsOverviewPage *self) self->loading_recent = TRUE; plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT, "age", (guint64) (60 * 60 * 24 * 60), - "max-results", 20, + /* To have large-enough set, in case filtering removes some non-applicable apps */ + "max-results", 3 * N_TILES, "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING | GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON, "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED | GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES, NULL); + gs_plugin_job_set_sort_func (plugin_job, gs_overview_page_sort_recent_cb, NULL); gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job, self->cancellable, -- GitLab From 00d80caff1d63ca3698fcbb2deb85ee9d1b4bee5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 25 Feb 2022 12:24:13 +0100 Subject: [PATCH 6/6] gs-overview-page: Get recent applications for the past 30 days only No need to get recent apps for 60 days, 30 days is enough. --- src/gs-overview-page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c index 36463030a..66a873153 100644 --- a/src/gs-overview-page.c +++ b/src/gs-overview-page.c @@ -526,7 +526,7 @@ gs_overview_page_load (GsOverviewPage *self) self->loading_recent = TRUE; plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT, - "age", (guint64) (60 * 60 * 24 * 60), + "age", (guint64) (60 * 60 * 24 * 30), /* To have large-enough set, in case filtering removes some non-applicable apps */ "max-results", 3 * N_TILES, "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING | -- GitLab