All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: yocto@yoctoproject.org
Subject: [layerindex-web][PATCH 2/6] Add statistics page
Date: Tue, 20 Feb 2018 16:45:54 +1300	[thread overview]
Message-ID: <20180220034558.14341-2-paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <20180220034558.14341-1-paul.eggleton@linux.intel.com>

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>
---
 layerindex/urls.py              |  6 ++++-
 layerindex/views.py             | 17 ++++++++++++
 templates/base.html             |  1 +
 templates/layerindex/stats.html | 60 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 templates/layerindex/stats.html

diff --git a/layerindex/urls.py b/layerindex/urls.py
index 7deaf23..d2f9eab 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 4f6c2c9..95812ca 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
diff --git a/templates/base.html b/templates/base.html
index 8a3b8fe..a9d7c83 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -73,6 +73,7 @@
                             <li><a href="{% url 'bulk_change' %}">Bulk Change</a></li>
                             <li><a href="{% url 'duplicates' 'master' %}">Duplicates</a></li>
                             <li><a href="{% url 'update_list' %}">Updates</a></li>
+                            <li><a href="{% url 'stats' %}">Statistics</a></li>
                         </ul>
                     </li>
                     {% endif %}
diff --git a/templates/layerindex/stats.html b/templates/layerindex/stats.html
new file mode 100644
index 0000000..3c4971b
--- /dev/null
+++ b/templates/layerindex/stats.html
@@ -0,0 +1,60 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load static %}
+
+{% comment %}
+
+  layerindex-web - statistics page template
+
+  Copyright (C) 2018 Intel Corporation
+  Licensed under the MIT license, see COPYING.MIT for details
+
+{% endcomment %}
+
+
+<!--
+{% block title_append %} - statistics{% endblock %}
+-->
+
+{% block content %}
+{% autoescape on %}
+
+<h2>Statistics</h2>
+
+<h3>Overall</h3>
+<dl class="dl-horizontal">
+    <dt>Layers</dt><dd>{{ layercount }}</dd>
+    <dt>Recipes</dt><dd>{{ recipe_count_distinct }} (distinct names)</dd>
+    <dt>Machines</dt><dd>{{ machine_count_distinct }} (distinct names)</dd>
+    <dt>Classes</dt><dd>{{ class_count_distinct }} (distinct names)</dd>
+    <dt>Distros</dt><dd>{{ distro_count_distinct }} (distinct names)</dd>
+</dl>
+
+<h3>Per branch</h3>
+
+<table class="table">
+    <thead>
+        <th>Branch</th>
+        <th style="text-align: right">Layers</th>
+        <th style="text-align: right">Recipes</th>
+        <th style="text-align: right">Machines</th>
+        <th style="text-align: right">Classes</th>
+        <th style="text-align: right">Distros</th>
+    </thead>
+    <tbody>
+        {% for branch in perbranch %}
+        <tr {% if not branch.updates_enabled %}class="muted"{% endif %}>
+            <td>{{ branch.name }}</td>
+            <td style="text-align: right">{{ branch.layer_count }}</td>
+            <td style="text-align: right">{{ branch.recipe_count }}</td>
+            <td style="text-align: right">{{ branch.machine_count }}</td>
+            <td style="text-align: right">{{ branch.class_count }}</td>
+            <td style="text-align: right">{{ branch.distro_count }}</td>
+        </tr>
+        {% endfor %}
+    </tbody>
+</table>
+
+{% endautoescape %}
+{% endblock %}
+
-- 
2.14.3



  reply	other threads:[~2018-02-20  3:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  3:45 [layerindex-web][PATCH 1/6] update.py: fix Ctrl+C behaviour Paul Eggleton
2018-02-20  3:45 ` Paul Eggleton [this message]
2018-02-20  3:45 ` [layerindex-web][PATCH 3/6] Show layer description with newlines in layer detail Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 4/6] requirements.txt: add missing dependencies Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 5/6] requirements.txt: update some dependency versions Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 6/6] README: update " Paul Eggleton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180220034558.14341-2-paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.