[gnome-software] appstream plugin: Remove popular app heuristics
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] appstream plugin: Remove popular app heuristics
- Date: Wed, 25 Mar 2015 18:16:36 +0000 (UTC)
commit ac4a3085d9e0fba57b64f30ae53c19ff0d0a1cd5
Author: Kalev Lember <kalevlember gmail com>
Date: Mon Mar 16 16:49:27 2015 +0100
appstream plugin: Remove popular app heuristics
As a side effect, this regresses the category of day, which the
following commits fix up.
https://bugzilla.gnome.org/show_bug.cgi?id=746036
src/plugins/gs-plugin-appstream.c | 294 -------------------------------------
src/plugins/gs-plugin-moduleset.c | 1 -
2 files changed, 0 insertions(+), 295 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 39c842c..4045047 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -1053,297 +1053,3 @@ out:
gs_profile_stop (plugin->profile, "appstream::add-categories");
return ret;
}
-
-/**
- * gs_plugin_appstream_is_app_awesome:
- */
-static gboolean
-gs_plugin_appstream_is_app_awesome (GsApp *app)
-{
- if ((gs_app_get_kudos (app) & GS_APP_KUDO_PERFECT_SCREENSHOTS) == 0)
- return FALSE;
- if (gs_app_get_kudos_weight (app) < 4)
- return FALSE;
- return TRUE;
-}
-
-/**
- * gs_plugin_add_popular_from_category:
- */
-static gboolean
-gs_plugin_add_popular_from_category (GsPlugin *plugin,
- GList **list,
- const gchar *category,
- const gchar *category_exclude,
- GHashTable *ignore_apps,
- GError **error)
-{
- AsApp *item;
- GError *error_local = NULL;
- GPtrArray *array;
- guint i;
-
- /* search categories for the search term */
- array = as_store_get_apps (plugin->priv->store);
- for (i = 0; i < array->len; i++) {
- _cleanup_object_unref_ GsApp *app = NULL;
- item = g_ptr_array_index (array, i);
-
- /* find not-installed desktop application with long descriptions
- * and perfect screenshots and that we've not suggested before */
- if (as_app_get_state (item) == AS_APP_STATE_INSTALLED)
- continue;
- if (as_app_get_id_kind (item) != AS_ID_KIND_DESKTOP)
- continue;
- if (as_app_get_description (item, NULL) == NULL)
- continue;
- if (g_hash_table_lookup (ignore_apps, as_app_get_id (item)) != NULL)
- continue;
- if (!as_app_has_category (item, category))
- continue;
- if (category_exclude != NULL && as_app_has_category (item, category_exclude))
- continue;
- if (plugin->priv->has_hi_dpi_support &&
- !as_app_has_kudo_kind (item, AS_KUDO_KIND_HI_DPI_ICON))
- continue;
-
- /* add application */
- app = gs_app_new (as_app_get_id (item));
- if (!gs_plugin_refine_item (plugin, app, item, &error_local)) {
- g_warning ("Failed to refine %s: %s",
- as_app_get_id (item),
- error_local->message);
- g_clear_error (&error_local);
- continue;
- }
-
- /* only suggest awesome applications */
- if (gs_plugin_appstream_is_app_awesome (app)) {
- g_debug ("suggesting %s as others installed from category %s",
- as_app_get_id (item), category);
- gs_plugin_add_app (list, app);
- g_hash_table_insert (ignore_apps,
- (gpointer) as_app_get_id (item),
- GINT_TO_POINTER (1));
- }
- }
- return TRUE;
-}
-
-/**
- * gs_plugin_add_popular_by_cat:
- */
-static gboolean
-gs_plugin_add_popular_by_cat (GsPlugin *plugin,
- GList **list,
- const gchar *category_exclude,
- GHashTable *ignore_apps,
- GCancellable *cancellable,
- GError **error)
-{
- AsApp *item;
- GPtrArray *array;
- GPtrArray *categories;
- const gchar *tmp;
- gboolean ret = TRUE;
- guint i;
- guint j;
- _cleanup_hashtable_unref_ GHashTable *ignore_cats = NULL;
-
- /* ignore main categories */
- gs_profile_start (plugin->profile, "appstream::add_popular[cat]");
- ignore_cats = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (ignore_cats, (gpointer) "Audio", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Development", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Education", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Game", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Graphics", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Network", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Office", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Science", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "System", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Utility", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Video", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Addons", GINT_TO_POINTER (1));
-
- /* ignore core apps */
- g_hash_table_insert (ignore_cats, (gpointer) "Core", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "PackageManager", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "TerminalEmulator", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "Settings", GINT_TO_POINTER (1));
- g_hash_table_insert (ignore_cats, (gpointer) "other", GINT_TO_POINTER (1));
-
- /* search categories for the search term */
- array = as_store_get_apps (plugin->priv->store);
- for (i = 0; i < array->len; i++) {
- item = g_ptr_array_index (array, i);
-
- /* find installed desktop applications */
- if (as_app_get_state (item) != AS_APP_STATE_INSTALLED)
- continue;
- if (as_app_get_id_kind (item) != AS_ID_KIND_DESKTOP)
- continue;
- if (as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_DESKTOP)
- continue;
-
- /* find non-installed apps with appdata in any category */
- categories = as_app_get_categories (item);
- for (j = 0; j < categories->len; j++) {
- tmp = g_ptr_array_index (categories, j);
- if (g_hash_table_lookup (ignore_cats, tmp) != NULL)
- continue;
- ret = gs_plugin_add_popular_from_category (plugin,
- list,
- tmp,
- category_exclude,
- ignore_apps,
- error);
- if (!ret)
- goto out;
- }
-
- }
-out:
- gs_profile_stop (plugin->profile, "appstream::add_popular[cat]");
- return ret;
-}
-
-/**
- * gs_plugin_add_popular_by_source:
- */
-static gboolean
-gs_plugin_add_popular_by_source (GsPlugin *plugin,
- GList **list,
- GCancellable *cancellable,
- GError **error)
-{
- AsApp *item;
- GPtrArray *array;
- gboolean ret = TRUE;
- guint i;
- _cleanup_hashtable_unref_ GHashTable *installed = NULL; /* srcpkg : AsApp */
-
- /* get already installed applications */
- gs_profile_start (plugin->profile, "appstream::add_popular[source]");
- installed = g_hash_table_new (g_str_hash, g_str_equal);
- array = as_store_get_apps (plugin->priv->store);
- for (i = 0; i < array->len; i++) {
- item = g_ptr_array_index (array, i);
- if (as_app_get_state (item) != AS_APP_STATE_INSTALLED)
- continue;
- if (as_app_get_id_kind (item) != AS_ID_KIND_DESKTOP)
- continue;
- if (as_app_get_source_pkgname (item) == NULL)
- continue;
- g_hash_table_insert (installed,
- (gpointer) as_app_get_source_pkgname (item),
- (gpointer) item);
- }
-
- /* search categories for the search term */
- for (i = 0; i < array->len; i++) {
- _cleanup_object_unref_ GsApp *app = NULL;
- item = g_ptr_array_index (array, i);
-
- /* find not installed desktop applications */
- if (as_app_get_state (item) == AS_APP_STATE_INSTALLED)
- continue;
- if (as_app_get_id_kind (item) != AS_ID_KIND_DESKTOP)
- continue;
- if (as_app_get_source_pkgname (item) == NULL)
- continue;
-
- /* have we got an app installed with the same source name */
- if (g_hash_table_lookup (installed, as_app_get_source_pkgname (item)) == NULL)
- continue;
-
- /* add application */
- app = gs_app_new (as_app_get_id (item));
- ret = gs_plugin_refine_item (plugin, app, item, error);
- if (!ret)
- goto out;
-
- /* only suggest awesome apps */
- if (gs_plugin_appstream_is_app_awesome (app)) {
- g_debug ("suggesting %s as others installed from source %s",
- as_app_get_id (item),
- as_app_get_source_pkgname (item));
- gs_plugin_add_app (list, app);
- } else {
- g_debug ("not suggesting %s as not awesome enough",
- as_app_get_id (item));
- }
- }
-out:
- gs_profile_stop (plugin->profile, "appstream::add_popular[source]");
- return ret;
-}
-
-/**
- * gs_plugin_add_popular:
- */
-gboolean
-gs_plugin_add_popular (GsPlugin *plugin,
- GList **list,
- const gchar *category,
- const gchar *category_exclude,
- GCancellable *cancellable,
- GError **error)
-{
- AsApp *item;
- GPtrArray *array;
- gboolean ret = TRUE;
- guint i;
- _cleanup_hashtable_unref_ GHashTable *ignore_apps = NULL;
-
- /* load XML files */
- if (g_once_init_enter (&plugin->priv->done_init)) {
- ret = gs_plugin_startup (plugin, error);
- g_once_init_leave (&plugin->priv->done_init, TRUE);
- if (!ret)
- goto out;
- }
- gs_profile_start (plugin->profile, "appstream::add_popular");
-
- /* get already installed applications */
- ignore_apps = g_hash_table_new (g_str_hash, g_str_equal);
- array = as_store_get_apps (plugin->priv->store);
- for (i = 0; i < array->len; i++) {
- item = g_ptr_array_index (array, i);
- if (as_app_get_state (item) != AS_APP_STATE_INSTALLED)
- continue;
- g_hash_table_insert (ignore_apps,
- (gpointer) as_app_get_id (item),
- GINT_TO_POINTER (1));
- }
-
- if (category == NULL) {
- /* use category heuristic */
- ret = gs_plugin_add_popular_by_cat (plugin,
- list,
- category_exclude,
- ignore_apps,
- cancellable,
- error);
- if (!ret)
- goto out;
-
- /* use source-package heuristic */
- ret = gs_plugin_add_popular_by_source (plugin, list, cancellable, error);
- if (!ret)
- goto out;
- } else {
- ret = gs_plugin_add_popular_from_category (plugin,
- list,
- category,
- NULL,
- ignore_apps,
- error);
- if (!ret)
- goto out;
- }
-
-out:
- gs_profile_stop (plugin->profile, "appstream::add_popular");
- return ret;
-}
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index 120601a..3c21e6b 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -51,7 +51,6 @@ const gchar **
gs_plugin_get_deps (GsPlugin *plugin)
{
static const gchar *deps[] = {
- "appstream", /* requires id */
"packagekit", /* pkgname */
NULL };
return deps;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]