aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-01-11 23:13:31 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-02-20 16:00:13 +1300
commitbed43a9be53a2f1722be75fb4bd63a6d7a94afaa (patch)
tree7113305e17f2973d2b9af96b7602f62d7ef23467 /layerindex
parentb614cba8174c97461460f7c6d0437704631420b2 (diff)
downloadopenembedded-core-contrib-bed43a9be53a2f1722be75fb4bd63a6d7a94afaa.tar.gz
Add statistics page
Add a page with basic statistics for the index - number of layers, recipes, classes, machines and distros on an overall basis (distinct names) and per branch, since I've been asked a few times for this kind of information. It's currently only linked from the Tools menu for logged-in users, but the URL will work for anyone. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex')
-rw-r--r--layerindex/urls.py6
-rw-r--r--layerindex/views.py17
2 files changed, 22 insertions, 1 deletions
diff --git a/layerindex/urls.py b/layerindex/urls.py
index 7deaf230bc..d2f9eab228 100644
--- a/layerindex/urls.py
+++ b/layerindex/urls.py
@@ -8,7 +8,7 @@ from django.conf.urls import *
from django.views.generic import TemplateView, DetailView, ListView, RedirectView
from django.views.defaults import page_not_found
from django.core.urlresolvers import reverse_lazy
-from layerindex.views import LayerListView, LayerReviewListView, LayerReviewDetailView, RecipeSearchView, MachineSearchView, PlainTextListView, LayerDetailView, edit_layer_view, delete_layer_view, edit_layernote_view, delete_layernote_view, HistoryListView, EditProfileFormView, AdvancedRecipeSearchView, BulkChangeView, BulkChangeSearchView, bulk_change_edit_view, bulk_change_patch_view, BulkChangeDeleteView, RecipeDetailView, RedirectParamsView, ClassicRecipeSearchView, ClassicRecipeDetailView, ClassicRecipeStatsView, LayerUpdateDetailView, UpdateListView, UpdateDetailView
+from layerindex.views import LayerListView, LayerReviewListView, LayerReviewDetailView, RecipeSearchView, MachineSearchView, PlainTextListView, LayerDetailView, edit_layer_view, delete_layer_view, edit_layernote_view, delete_layernote_view, HistoryListView, EditProfileFormView, AdvancedRecipeSearchView, BulkChangeView, BulkChangeSearchView, bulk_change_edit_view, bulk_change_patch_view, BulkChangeDeleteView, RecipeDetailView, RedirectParamsView, ClassicRecipeSearchView, ClassicRecipeDetailView, ClassicRecipeStatsView, LayerUpdateDetailView, UpdateListView, UpdateDetailView, StatsView
from layerindex.models import LayerItem, Recipe, RecipeChangeset
from rest_framework import routers
from . import restviews
@@ -127,6 +127,10 @@ urlpatterns = patterns('',
TemplateView.as_view(
template_name='layerindex/about.html'),
name="about"),
+ url(r'^stats/$',
+ StatsView.as_view(
+ template_name='layerindex/stats.html'),
+ name='stats'),
url(r'^oe-classic/$',
RedirectView.as_view(url=reverse_lazy('classic_recipe_search'), permanent=False),
name='classic'),
diff --git a/layerindex/views.py b/layerindex/views.py
index 4f6c2c9df8..95812ca29f 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -1007,3 +1007,20 @@ class ClassicRecipeStatsView(TemplateView):
'jquery_on_ready': False,
}
return context
+
+
+class StatsView(TemplateView):
+ def get_context_data(self, **kwargs):
+ context = super(StatsView, self).get_context_data(**kwargs)
+ context['layercount'] = LayerItem.objects.count()
+ context['recipe_count_distinct'] = Recipe.objects.values('pn').distinct().count()
+ context['class_count_distinct'] = BBClass.objects.values('name').distinct().count()
+ context['machine_count_distinct'] = Machine.objects.values('name').distinct().count()
+ context['distro_count_distinct'] = Distro.objects.values('name').distinct().count()
+ context['perbranch'] = Branch.objects.order_by('sort_priority').annotate(
+ layer_count=Count('layerbranch', distinct=True),
+ recipe_count=Count('layerbranch__recipe', distinct=True),
+ class_count=Count('layerbranch__bbclass', distinct=True),
+ machine_count=Count('layerbranch__machine', distinct=True),
+ distro_count=Count('layerbranch__distro', distinct=True))
+ return context