diff --git a/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html b/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html
index 25fb881..e617866 100644
--- a/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html
+++ b/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html
@@ -51,35 +51,41 @@
-
{{aggregate_previous_event.0.event_name}}
+
{{aggregate_current_event.0.event_name}}
| {% trans "Period" %} |
{% trans "# tickets" %} |
+ {% if aggregate_previous_event.0.event_name %}
+ Diff with {{aggregate_previous_event.0.event_name}} |
+ {% endif %}
- {% with start_month=aggregate_previous_event.0.month_name|slice:":3" %}
- {% for r in aggregate_previous_event|slice:"1:" %}
+ {% with start_month=aggregate_current_event.0.month_name|slice:":3" %}
+ {% for r in aggregate_current_event|slice:"1:" %}
| {{ start_month }}-{{ r.month_name|slice:":3" }} |
{{r.cumulative_count}} |
+ {% if aggregate_previous_event.0.event_name %}
+ {{r.diff}} |
+ {% endif %}
{% endfor %}
{% endwith %}
-
+ {% if aggregate_previous_event.0.event_name %}
-
{{aggregate_current_event.0.event_name}}
+
{{aggregate_previous_event.0.event_name}}
| {% trans "Period" %} |
{% trans "# tickets" %} |
- {% with start_month=aggregate_current_event.0.month_name|slice:":3" %}
- {% for r in aggregate_current_event|slice:"1:" %}
+ {% with start_month=aggregate_previous_event.0.month_name|slice:":3" %}
+ {% for r in aggregate_previous_event|slice:"1:" %}
| {{ start_month }}-{{ r.month_name|slice:":3" }} |
{{r.cumulative_count}} |
@@ -89,11 +95,11 @@ {{aggregate_current_event.0.event_name}}
+ {% endif %}
-
{%endif%}
{% endblock content %}
\ No newline at end of file
diff --git a/pretix_advanced_stats/views.py b/pretix_advanced_stats/views.py
index 75c84e6..8222091 100644
--- a/pretix_advanced_stats/views.py
+++ b/pretix_advanced_stats/views.py
@@ -130,8 +130,19 @@ def get_context_data(self, **kwargs):
if comparison_event
else None
)
- aggregate_previous_event = self.cumulative_tickets(tickets_previous_event)
+ aggregate_previous_event = (
+ self.cumulative_tickets(tickets_previous_event)
+ if tickets_previous_event
+ else []
+ )
aggregate_current_event = self.cumulative_tickets(tickets_current_event)
+ if aggregate_previous_event:
+ for r_current, r_previous in zip(
+ aggregate_current_event, aggregate_previous_event
+ ):
+ r_current["diff"] = (
+ r_current["cumulative_count"] - r_previous["cumulative_count"]
+ )
ctx.update(
{
"events": [