Sessions
{{stats.session_count|intcomma}} +
diff --git a/shynet/core/models.py b/shynet/core/models.py index 8625204..540f8e2 100644 --- a/shynet/core/models.py +++ b/shynet/core/models.py @@ -59,6 +59,13 @@ class Service(models.Model): if end_time is None: end_time = timezone.now() + main_data = self.get_relative_stats(start_time, end_time) + comparison_data = self.get_relative_stats(start_time - (end_time - start_time), start_time) + main_data["compare"] = comparison_data + + return main_data + + def get_relative_stats(self, start_time, end_time): Session = apps.get_model("analytics", "Session") Hit = apps.get_model("analytics", "Hit") diff --git a/shynet/dashboard/templates/dashboard/includes/service_overview.html b/shynet/dashboard/templates/dashboard/includes/service_overview.html index 53981e7..4394890 100644 --- a/shynet/dashboard/templates/dashboard/includes/service_overview.html +++ b/shynet/dashboard/templates/dashboard/includes/service_overview.html @@ -12,17 +12,24 @@
Sessions
-{{stats.session_count|intcomma}}
++ {{stats.session_count|intcomma}} + {% compare stats.compare.session_count stats.session_count "UP" %} +
Hits
-{{stats.hit_count|intcomma}}
++ {{stats.hit_count|intcomma}} + {% compare stats.compare.hit_count stats.hit_count "UP" %} +
Bounce Rate
{% if stats.bounce_rate_pct != None %} {{stats.bounce_rate_pct|floatformat:"-1"}}% + {% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" %} {% else %} ? {% endif %} @@ -33,6 +40,7 @@
{% if stats.avg_session_duration != None %} {{stats.avg_session_duration|naturaldelta}} + {% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" %} {% else %} ? {% endif %} diff --git a/shynet/dashboard/templates/dashboard/includes/stat_comparison.html b/shynet/dashboard/templates/dashboard/includes/stat_comparison.html new file mode 100644 index 0000000..5e24eee --- /dev/null +++ b/shynet/dashboard/templates/dashboard/includes/stat_comparison.html @@ -0,0 +1,7 @@ +{% load helpers %} + + + {% percent_change_display start end %} + \ No newline at end of file diff --git a/shynet/dashboard/templates/dashboard/pages/service.html b/shynet/dashboard/templates/dashboard/pages/service.html index 1d45a9e..303256a 100644 --- a/shynet/dashboard/templates/dashboard/pages/service.html +++ b/shynet/dashboard/templates/dashboard/pages/service.html @@ -12,16 +12,23 @@ {% block service_content %}
Sessions
{{stats.session_count|intcomma}} +
Hits
{{stats.hit_count|intcomma}} +
{% if stats.avg_load_time %} {{stats.avg_load_time|floatformat:"0"}}ms +
{% if stats.bounce_rate_pct %} {{stats.bounce_rate_pct|floatformat:"-1"}}% +
{% if stats.avg_session_duration %} {{stats.avg_session_duration|naturaldelta}} +
{% if stats.avg_hits_per_session %} {{stats.avg_hits_per_session|floatformat:"-1"}} +