diff --git a/analytics/views.py b/analytics/views.py
index 9124741..2e26422 100644
--- a/analytics/views.py
+++ b/analytics/views.py
@@ -64,15 +64,22 @@ def most_active_users_in_a_month(request):
for day in days:
built_date = date(int(year), mappings[_(month)], day)
days_list.append(built_date)
- data = activity_in_timestamp(days_list)
+ data = activity_in_timestamp(days_list, params = params)
data = [{"day": day.day, "count": day_count} for day, day_count in data.items()]
return JsonResponse(data, safe=False)
-def activity_in_timestamp(days):
+def activity_in_timestamp(days, **kwargs):
data = {}
+ params = kwargs.get('params')
+ print(params)
for day in days:
- day_count = Log.objects.filter(datetime__date = day).count()
+ if params.get('category_id'):
+ category_id = params['category_id']
+ day_count = Log.objects.filter(datetime__date = day, context__contains = {"category_id" : int(category_id)}).count()
+
+ else:
+ day_count = Log.objects.filter(datetime__date = day).count()
data[day] = day_count
return data
@@ -184,10 +191,12 @@ def most_active_users(request):
def get_days_of_the_week_log(request):
- date = request.GET['date']
+
+ params = request.GET
+ date = params['date']
date = datetime.strptime( date, '%m/%d/%Y',)
days = get_days_of_the_week(date)
- data = activity_in_timestamp(days)
+ data = activity_in_timestamp(days, params = params)
#mapping of number to days
mapping = {0: _("Mon"), 1: _("Tue"), 2: _("Wed"), 3: _("Thu"), 4: _("Fri"), 5: _("Sat"), 6: _("Sun")}
data = [{"day": mapping[day.weekday()], "count": day_count} for day, day_count in data.items()]
diff --git a/dashboards/static/dashboards/js/behavior.js b/dashboards/static/dashboards/js/behavior.js
index 9399225..fdde3b3 100644
--- a/dashboards/static/dashboards/js/behavior.js
+++ b/dashboards/static/dashboards/js/behavior.js
@@ -7,28 +7,6 @@ $(document).ready(function(){
charts.most_used_tags('/analytics/most_used_tags');
charts.build_bubble_user('/analytics/most_active_users/');
-
- $('#month_selector').change(function(){
-
- var date = $(this).val().split("/");
- $.get('/analytics/amount_active_users_per_day', {month: date[0], year: date[1] }).done(function(data){
- charts.month_heatmap(data, '#right-chart-body', 'month-chart');
-
- });
- });
- //week date selector at the right-chart field
- $('input.datepicker').datetimepicker({
- format: 'L',
- defaultDate: new Date(),
- }).on('dp.change', function(ev){
- new_date = new Date(ev.date);
- var date = (new_date.getMonth() + 1) + '/' + new_date.getDate() + '/' + new_date.getFullYear();
- $.get('/analytics/get_days_of_the_week_log', {date: date}).done(function(data){
- charts.month_heatmap(data, '#bottom-right-chart-body', 'weekly-chart');
- });
-
- });
-
//first call to month selector
var month = new Array();
@@ -56,6 +34,28 @@ $(document).ready(function(){
});
+ //update month heatmap when the month selector is changed
+ $('#month_selector').change(function(){
+
+ var date = $(this).val().split("/");
+ $.get('/analytics/amount_active_users_per_day', {month: date[0], year: date[1] }).done(function(data){
+ charts.month_heatmap(data, '#right-chart-body', 'month-chart');
+
+ });
+ });
+
+ //week date selector at the right-chart field
+ $('input.datepicker').datetimepicker({
+ format: 'L',
+ defaultDate: new Date(),
+ }).on('dp.change', function(ev){
+ new_date = new Date(ev.date);
+ var date = (new_date.getMonth() + 1) + '/' + new_date.getDate() + '/' + new_date.getFullYear();
+ $.get('/analytics/get_days_of_the_week_log', {date: date}).done(function(data){
+ charts.month_heatmap(data, '#bottom-right-chart-body', 'weekly-chart');
+ });
+
+ });
});
diff --git a/dashboards/static/dashboards/js/behavior_categories.js b/dashboards/static/dashboards/js/behavior_categories.js
index 94c7e0a..5c22042 100644
--- a/dashboards/static/dashboards/js/behavior_categories.js
+++ b/dashboards/static/dashboards/js/behavior_categories.js
@@ -3,8 +3,58 @@ $(document).ready(function(){
$("#category-selector").on("change", function(e){
//when it changes, the tag chart is replaced and all others are.
- category_id = $(e.target).val();
+ var category_id = $(e.target).val();
charts.most_used_tags('/analytics/get_category_tags/?category_id='+category_id);
+
+
+ //first call to month selector
+ var month = new Array();
+ month[0] = "January";
+ month[1] = "February";
+ month[2] = "March";
+ month[3] = "April";
+ month[4] = "May";
+ month[5] = "June";
+ month[6] = "July";
+ month[7] = "August";
+ month[8] = "September";
+ month[9] = "October";
+ month[10] = "November";
+ month[11] = "December";
+
+
+ $.get('/analytics/amount_active_users_per_day', { month: month[(new Date()).getMonth()], category_id: category_id }).done(function(data){
+ charts.month_heatmap(data, '#right-side-heatmaps', 'month-chart');
+ });
+
});
-});
+
+
+
+
+ $('#month_selector').change(function(){
+
+ var date = $(this).val().split("/");
+ $.get('/analytics/amount_active_users_per_day', {month: date[0], year: date[1], category_id: $("#category-selector").val() }).done(function(data){
+ charts.month_heatmap(data, '#right-side-heatmaps', 'month-chart');
+
+ });
+ });
+
+ //week date selector at the right-chart field
+ $('input.datepicker').datetimepicker({
+ format: 'L',
+ defaultDate: new Date(),
+ }).on('dp.change', function(ev){
+ new_date = new Date(ev.date);
+ var date = (new_date.getMonth() + 1) + '/' + new_date.getDate() + '/' + new_date.getFullYear();
+ $.get('/analytics/get_days_of_the_week_log', {date: date}).done(function(data){
+ charts.month_heatmap(data, '#bottom-right-chart-body', 'weekly-chart');
+ });
+
+ });
+
+
+
+});
diff --git a/dashboards/static/dashboards/js/logbehavior.js b/dashboards/static/dashboards/js/logbehavior.js
index 7a86799..7f7b4d1 100644
--- a/dashboards/static/dashboards/js/logbehavior.js
+++ b/dashboards/static/dashboards/js/logbehavior.js
@@ -70,7 +70,9 @@ var log = {
"limit": 20, //maximum number of elements per page
});*/
- $('#log-table').DataTable();
+ $('#log-table').DataTable({
+ "pageLength": 100
+ });
},
}
diff --git a/dashboards/templates/dashboards/category.html b/dashboards/templates/dashboards/category.html
index 9e2be5f..24d34f3 100644
--- a/dashboards/templates/dashboards/category.html
+++ b/dashboards/templates/dashboards/category.html
@@ -3,13 +3,16 @@
{% load static i18n pagination %}
{% load django_bootstrap_breadcrumbs %}
{% block style %}
-
-
+ {% for file in style_files %}
+
+ {% endfor %}
{% endblock style %}
{% block javascript %}
-
-
+
+ {% for file in javascript_files %}
+
+ {% endfor %}
{% endblock javascript %}
{% block breadcrumbs %}
@@ -27,14 +30,18 @@