Skip to content
Snippets Groups Projects
Commit ded2aab0 authored by Andreas Valder's avatar Andreas Valder
Browse files

added a first statistic for a test

parent 373f200e
No related branches found
No related tags found
No related merge requests found
......@@ -539,12 +539,6 @@ def auth(): # For use with nginx auth_request
return Response("Login required", 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
return "Not allowed", 403
@app.route('/stats')
@register_navbar('Statistiken', icon='stats')
@mod_required
def stats():
return render_template('stats.html')
@app.route('/changelog')
@register_navbar('Changelog', icon='book')
@mod_required
......@@ -609,6 +603,7 @@ def sitemap():
import feeds
import importer
import stats
import sorter
if 'ICAL_URL' in config:
import meetings
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
stats.py 0 → 100644
from server import *
import json
@app.route('/stats')
@register_navbar('Statistiken', icon='stats')
@mod_required
def stats():
return render_template('stats.html')
statsqueries = {}
statsqueries['course_count'] = "SELECT count(id) as count, semester FROM courses GROUP BY semester;"
@app.route('/stats/data/<dataname>')
@app.route('/stats/data/<dataname>/<parameter>')
@mod_required
def stats_data(dataname, parameter=None):
if parameter:
data = query(statsqueries[dataname],parameter)
else:
data = query(statsqueries[dataname])
return Response(json.dumps(data), mimetype='application/json')
......@@ -25,7 +25,9 @@
<script src="{{url_for('static', filename='jquery.js')}}"></script>
<script src="{{url_for('static', filename='bootstrap/bootstrap.js')}}"></script>
<script src="{{url_for('static', filename='js.cookie.js')}}"></script>
{%if ismod() %}<script src="{{url_for('static', filename='moderator.js')}}"></script>{% endif %}
{%if ismod() %}
<script src="{{url_for('static', filename='moderator.js')}}"></script>
{% endif %}
<script src="{{url_for('static', filename='videojs/video.js')}}"></script>
<script src="{{url_for('static', filename='videojs/ie8/videojs-ie8.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js')}}"></script>
......
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% block header %}
{{ super() }}
<script src="{{url_for('static', filename='plotly.min.js')}}"></script>
{% endblock %}
{% block content %}
<div class="panel-group">
<div class="panel panel-default">
......@@ -7,6 +13,29 @@
<h1 class="panel-title">Statistiken</h1>
</div>
<div class="panel-body">
<div id="tester" style="width:600px;height:600px;"></div>
<script>
$.ajax({
method: "GET",
url: "/stats/data/course_count",
dataType: "json",
error: moderator.api.handleapierror,
success: function (data) {
console.log(data);
var semester = [];
var y = [];
var x = []
for (var i=0; i < data.length; i++) {
semester.push(data[i].semester);
y.push(data[i].count);
x.push(i);
}
var trace = {"y": y, "x": semester, "type": "scatter"};
console.log(trace);
Plotly.newPlot('tester', [trace]);
}
});
</script>
</div>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment