Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,41 @@ <h3 class="panel-title">{% trans "Aggregate sellout" %}</h3>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<h4>{{aggregate_previous_event.0.event_name}}</h4>
<h4>{{aggregate_current_event.0.event_name}}</h4>
<table class="table">
<thead>
<th>{% trans "Period" %}</th>
<th>{% trans "# tickets" %}</th>
{% if aggregate_previous_event.0.event_name %}
<th>Diff with {{aggregate_previous_event.0.event_name}}</th >
{% endif %}
</thead>
<tbody>
{% 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:" %}
<tr>
<td>{{ start_month }}-{{ r.month_name|slice:":3" }}</td>
<td>{{r.cumulative_count}}</td>
{% if aggregate_previous_event.0.event_name %}
<td>{{r.diff}}</td>
{% endif %}
</tr>
{% endfor %}
{% endwith %}

</tbody>
</table>
</div>
{% if aggregate_previous_event.0.event_name %}
<div class="col-md-6">
<h4>{{aggregate_current_event.0.event_name}}</h4>
<h4>{{aggregate_previous_event.0.event_name}}</h4>
<table class="table">
<thead>
<th>{% trans "Period" %}</th>
<th>{% trans "# tickets" %}</th>
</thead>
<tbody>
{% 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:" %}
<tr>
<td>{{ start_month }}-{{ r.month_name|slice:":3" }}</td>
<td>{{r.cumulative_count}}</td>
Expand All @@ -89,11 +95,11 @@ <h4>{{aggregate_current_event.0.event_name}}</h4>
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
</div>

<script src="{% static "pretix_advanced_stats/stats.js" %}"></script>

{%endif%}
{% endblock content %}
13 changes: 12 additions & 1 deletion pretix_advanced_stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down