mirror of https://gitlab.federez.net/re2o/re2o
5 changed files with 100 additions and 4 deletions
@ -0,0 +1,50 @@ |
|||
from jchart import Chart |
|||
from jchart.config import Axes |
|||
|
|||
from users.models import User, Adherent |
|||
from re2o.utils import all_adherent |
|||
|
|||
from datetime import timedelta |
|||
from django.utils import timezone |
|||
from django.db.models import Count |
|||
|
|||
class ActiveUserChart(Chart): |
|||
"""Create the hart of all active users for the 3 last months""" |
|||
chart_type = 'line' |
|||
scales = {'xAxes': [Axes(type='time', position='bottom')]} |
|||
|
|||
|
|||
def get_datasets(self, **kwargs): |
|||
data=[] |
|||
for i in range(100): |
|||
d = timedelta(days=i) |
|||
date = timezone.now()-d |
|||
data.append({'x':date,'y':all_adherent(search_time=date).count()}) |
|||
|
|||
return [{ |
|||
'type': 'line', |
|||
'label': "Nombre d'utilisateur actifs", |
|||
'data': data |
|||
}] |
|||
|
|||
class MachinePerUserChart(Chart): |
|||
"""Create the chart displaying the number of machines per users |
|||
for the 20 firsts users""" |
|||
|
|||
qs = User.objects.annotate(num=Count('machine')).order_by('-num')[:20] |
|||
|
|||
chart_type = 'bar' |
|||
scales = {'xAxes': [Axes(type='category', position='bottom',)]} |
|||
|
|||
def get_labels(self, **kwargs): |
|||
qs = User.objects.annotate(num=Count('machine')).order_by('-num')[:20] |
|||
return [u.name for u in qs] |
|||
|
|||
def get_datasets(self, **kwargs): |
|||
qs = User.objects.annotate(num=Count('machine')).order_by('-num')[:20] |
|||
data=[u.num for u in qs] |
|||
|
|||
return [{ |
|||
'label': "Nombre de machines par utilisateurs", |
|||
'data': data |
|||
}] |
|||
@ -0,0 +1,37 @@ |
|||
{% extends "logs/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load i18n %} |
|||
|
|||
{% block title %}{% trans "Statistics" %}{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>{% trans "Graphiques" %}</h2> |
|||
{% include "logs/aff_charts.html" with charts_list=charts_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
Loading…
Reference in new issue