diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 7bb9bfca4..be184eb93 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -97,6 +97,8 @@ class="fas fa-sync-alt"> {% trans 'Configure Sync' %} {% trans 'Batch Edit' %} + {% trans 'Statistics' %} diff --git a/cookbook/templates/stats.html b/cookbook/templates/stats.html index 24b162fd3..e6211ad8a 100644 --- a/cookbook/templates/stats.html +++ b/cookbook/templates/stats.html @@ -10,5 +10,37 @@ {% trans 'Statistics' %} +
+
+
+
+ {% trans 'Number of Objects' %} +
+
    +
  • {% trans 'Recipes' %} : {{ counts.recipes }}
  • +
  • {% trans 'Categories' %} : {{ counts.categories }}
  • +
  • {% trans 'Keywords' %} : {{ counts.keywords }}
  • +
  • {% trans 'Recipe Imports' %} : {{ counts.recipe_import }}
  • +
+
+
+
+
+
+ {% trans 'Number of Objects' %} +
+
    +
  • {% trans 'Recipes without Category' %} : {{ counts.recipes_no_category }}
  • +
  • {% trans 'Recipes without Keywords' %} : {{ counts.recipes_no_keyword}}
  • +
+
+
+
{% endblock %} \ No newline at end of file diff --git a/cookbook/views/data.py b/cookbook/views/data.py index 27d7aff40..6273c30e7 100644 --- a/cookbook/views/data.py +++ b/cookbook/views/data.py @@ -6,8 +6,8 @@ from django.shortcuts import redirect, render from django.utils.translation import ngettext from django_tables2 import RequestConfig -from cookbook.forms import SyncForm, BatchEditForm, RecipeImport -from cookbook.models import Recipe, Sync +from cookbook.forms import SyncForm, BatchEditForm +from cookbook.models import * from cookbook.tables import SyncTable @@ -86,6 +86,19 @@ def batch_edit(request): return render(request, 'batch/edit.html', {'form': form}) +class Object(object): + pass + + @login_required def statistics(request): - return render(request, 'index.html') + counts = Object() + counts.recipes = Recipe.objects.count() + counts.categories = Category.objects.count() + counts.keywords = Keyword.objects.count() + counts.recipe_import = RecipeImport.objects.count() + + counts.recipes_no_category = Recipe.objects.filter(category__isnull=True).count() + counts.recipes_no_keyword = Recipe.objects.filter(keywords=None).count() + + return render(request, 'stats.html', {'counts': counts})