mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 09:12:23 +01:00
Basic statistics.
This commit is contained in:
@ -39,7 +39,8 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'marietje',
|
'marietje',
|
||||||
'queues',
|
'queues',
|
||||||
'songs'
|
'songs',
|
||||||
|
'stats'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Upload</a></li>
|
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Upload</a></li>
|
||||||
{% url 'songs:manage' as url %}
|
{% url 'songs:manage' as url %}
|
||||||
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Manage</a></li>
|
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Manage</a></li>
|
||||||
|
{% url 'stats:stats' as url %}
|
||||||
|
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Stats</a></li>
|
||||||
{% if user.is_superuser %}
|
{% if user.is_superuser %}
|
||||||
{% url 'admin:index' as url %}
|
{% url 'admin:index' as url %}
|
||||||
<li><a href="{{ url }}">Admin</a></li>
|
<li><a href="{{ url }}">Admin</a></li>
|
||||||
|
|||||||
@ -33,4 +33,5 @@ urlpatterns = [
|
|||||||
url(r'^songs/', include('songs.urls')),
|
url(r'^songs/', include('songs.urls')),
|
||||||
url(r'^api/', include('api.urls')),
|
url(r'^api/', include('api.urls')),
|
||||||
url(r'^playerapi/', include('playerapi.urls')),
|
url(r'^playerapi/', include('playerapi.urls')),
|
||||||
|
url(r'^stats/', include('stats.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
0
marietje/stats/__init__.py
Normal file
0
marietje/stats/__init__.py
Normal file
3
marietje/stats/admin.py
Normal file
3
marietje/stats/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
marietje/stats/apps.py
Normal file
5
marietje/stats/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class StatsConfig(AppConfig):
|
||||||
|
name = 'stats'
|
||||||
0
marietje/stats/migrations/__init__.py
Normal file
0
marietje/stats/migrations/__init__.py
Normal file
3
marietje/stats/models.py
Normal file
3
marietje/stats/models.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
46
marietje/stats/templates/stats/stats.html
Normal file
46
marietje/stats/templates/stats/stats.html
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block title %}Stats{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Statistics</h1>
|
||||||
|
<h2>Uploads</h2>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
<th># Songs</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for stat in upload_stats %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ stat.user__name }}</td>
|
||||||
|
<td>{{ stat.total }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h2>Requests</h2>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
<th># Requests</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for stat in request_stats %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ stat.user__name }}</td>
|
||||||
|
<td>{{ stat.total }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
3
marietje/stats/tests.py
Normal file
3
marietje/stats/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
9
marietje/stats/urls.py
Normal file
9
marietje/stats/urls.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'stats'
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$', views.stats, name='stats'),
|
||||||
|
]
|
||||||
10
marietje/stats/views.py
Normal file
10
marietje/stats/views.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
from django.db.models import Count
|
||||||
|
from songs.models import Song
|
||||||
|
from queues.models import PlaylistSong
|
||||||
|
|
||||||
|
|
||||||
|
def stats(request):
|
||||||
|
upload_stats = Song.objects.all().exclude(user_id=None).values('user__name').annotate(total=Count('id')).order_by('-total')
|
||||||
|
request_stats = PlaylistSong.objects.all().exclude(user_id=None).values('user__name').annotate(total=Count('id')).order_by('-total')
|
||||||
|
return render(request, 'stats/stats.html', {'upload_stats': upload_stats, 'request_stats': request_stats})
|
||||||
Reference in New Issue
Block a user