[recipes] Add API to get all contributors
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add API to get all contributors
- Date: Sun, 5 Mar 2017 16:12:52 +0000 (UTC)
commit 8e2346224b048b2901876cba56dbac7f91e3619c
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 5 11:07:52 2017 -0500
Add API to get all contributors
This returns an array with the names of all chefs which
have contributed recipes in the database.
src/gr-recipe-store.c | 23 +++++++++++++++++++++++
src/gr-recipe-store.h | 2 ++
2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index 724562e..0d955f1 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -1239,6 +1239,29 @@ gr_recipe_store_get_chef_keys (GrRecipeStore *self,
return (char **)g_hash_table_get_keys_as_array (self->chefs, length);
}
+char **
+gr_recipe_store_get_contributors (GrRecipeStore *self,
+ guint *length)
+{
+ GHashTableIter iter;
+ GrRecipe *recipe;
+ g_autoptr(GHashTable) chefs = NULL;
+
+ chefs = g_hash_table_new (g_str_hash, g_str_equal);
+
+ g_hash_table_iter_init (&iter, self->recipes);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&recipe)) {
+ if (gr_recipe_is_contributed (recipe)) {
+ GrChef *chef;
+
+ chef = g_hash_table_lookup (self->chefs, gr_recipe_get_author (recipe));
+ g_hash_table_add (chefs, (gpointer)gr_chef_get_fullname (chef));
+ }
+ }
+
+ return (char **)g_hash_table_get_keys_as_array (chefs, length);
+}
+
const char *
gr_recipe_store_get_user_key (GrRecipeStore *self)
{
diff --git a/src/gr-recipe-store.h b/src/gr-recipe-store.h
index f74851e..997de3a 100644
--- a/src/gr-recipe-store.h
+++ b/src/gr-recipe-store.h
@@ -91,6 +91,8 @@ gboolean gr_recipe_store_has_chef (GrRecipeStore *self,
GrChef *chef);
gboolean gr_recipe_store_has_cuisine (GrRecipeStore *self,
const char *cuisine);
+char ** gr_recipe_store_get_contributors (GrRecipeStore *self,
+ guint *length);
#define GR_TYPE_RECIPE_SEARCH (gr_recipe_search_get_type())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]