Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git@github.com:anttihirvonen/aaltoanalytics

  • Loading branch information...
commit 02cbf336ae6d8c7546213ed8f9f15138f60f5d43 2 parents 5ea5146 + 1a32fdc
@anttihirvonen authored
View
7 aaltoanalytics/apps/development/views.py
@@ -23,7 +23,12 @@ def development_index(request):
browsers = Pageview.objects.filter(datetime__gte=start_date, datetime__lte=end_date).values('browser_name').distinct()
for b in browsers:
b['user_count'] = Pageview.objects.filter(datetime__gte=start_date, datetime__lte=end_date, browser_name=b['browser_name']).values('user_id').distinct().count()
- return render(request, 'development/index.html', {'start_date' : start_date, 'end_date' : end_date, 'browsers' : browsers })
+ # Since sqlite doesn't seem to support distinct in certain cases, this is a hack
+ # -- works as a quick hack, but better solution needed..
+ oses = Pageview.objects.filter(datetime__gte=start_date, datetime__lte=end_date).values('operating_system').distinct()
+ for b in oses:
+ b['user_count'] = Pageview.objects.filter(datetime__gte=start_date, datetime__lte=end_date, operating_system=b['operating_system']).values('user_id').distinct().count()
+ return render(request, 'development/index.html', {'start_date' : start_date, 'end_date' : end_date, 'browsers' : browsers, 'oses' : oses })
def development_show_raw_log(request):
"""
View
46 aaltoanalytics/templates/development/index.html
@@ -4,7 +4,7 @@
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
-// Load the Visualization API and the piechart package.
+ // Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
@@ -14,28 +14,38 @@
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
-
+
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Browser');
data.addColumn('number', 'Users');
data.addRows([
- {% for b in browsers %}
- ['{{ b.browser_name }}',{{ b.user_count}}],
- {% endfor %}
- ]);
-
- // Set chart options
- var options = {'title':'Browser Marketshare',
+ {% for b in browsers %}
+ ['{{ b.browser_name }}',{{ b.user_count}}],
+ {% endfor %}
+ ]);
+
+ // Create the data table.
+ var data2 = new google.visualization.DataTable();
+ data2.addColumn('string', 'Operating System');
+ data2.addColumn('number', 'Users');
+ data2.addRows([
+ {% for b in oses %}
+ ['{{ b.operating_system }}',{{ b.user_count}}],
+ {% endfor %}
+ ]);
+
+ // Set chart options
+ var options = {'title':'Browser Marketshare',
height: 500};
-
- // Instantiate and draw our chart, passing in some options.
- var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- var chart = new google.visualization.PieChart(document.getElementById('chart_div2'));
- chart.draw(data, options);
- }
- </script>
+
+ // Instantiate and draw our chart, passing in some options.
+ var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
+ chart.draw(data, options);
+ var chart2 = new google.visualization.PieChart(document.getElementById('chart_div2'));
+ chart2.draw(data2, {'title':'Operating System Marketshare', height: 500});
+}
+</script>
{% endblock %}
{% block content %}
<div class="row">
@@ -54,4 +64,4 @@ <h1 style="text-align: center">Statistics</h1>
</div>
</div>
-{% endblock %}
+{% endblock %}
View
4 aaltoanalytics/templates/mobile/active_users_per_service.html
@@ -1,13 +1,13 @@
{% extends 'mobile/base.html' %}
{% block content %}
-<div data-role="header" data-theme="e">
+<div data-role="header">
<h1>Active users per service</h1>
<a href="{% url mobile-index %}" data-direction="reverse" data-iconpos="notext" data-icon="home">Home</a>
</div>
<div data-role="content">
<h2>Active users per service</h2>
- <ul data-role="listview">
+ <ul data-role="listview" data-divider-theme="a">
{% for service in services %}
<li>{{ service.name }} <span class="ui-li-count">{{ service.users }}</span></li>
{% endfor %}
View
2  aaltoanalytics/templates/mobile/most_viewed_content.html
@@ -6,7 +6,7 @@
</div>
<div data-role="content">
<h2>List of most viewed by service</h2>
- <ul data-role="listview">
+ <ul data-role="listview" data-divider-theme="a">
{% for entry in service_pageview_list %}
<li data-role="list-divider">{{ entry.service.name }}</li>
{% for pageview in entry.pageviews %}
Please sign in to comment.
Something went wrong with that request. Please try again.