fix time table
This commit is contained in:
@@ -266,9 +266,9 @@
|
||||
</div>
|
||||
<h6>Most Active Hours</h6>
|
||||
<!-- Calculate peak hours from data -->
|
||||
{% set peak_hours = [] %}
|
||||
{% set peak_hours = [] %}
|
||||
{% for item in reservations %}
|
||||
{% set slot = item.reservation.start_time.hour %}
|
||||
{% set slot = item.start_time.hour %}
|
||||
{% if slot not in peak_hours %}
|
||||
{% set _ = peak_hours.append(slot) %}
|
||||
{% endif %}
|
||||
@@ -290,19 +290,16 @@
|
||||
<i class="bi bi-building text-info" style="font-size: 2rem;"></i>
|
||||
</div>
|
||||
<h6>Busiest Classrooms</h6>
|
||||
{% set usage_counter = {} %}
|
||||
{% for item in reservations %}
|
||||
{% set code = item.classroom.code %}
|
||||
{% if code not in usage_counter %}
|
||||
{% set _ = usage_counter.update({code: 1}) %}
|
||||
{% else %}
|
||||
{% set _ = usage_counter.update({code: usage_counter[code] + 1}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<p class="text-muted">
|
||||
{% if usage_counter %}
|
||||
{% for code, count in usage_counter.items()|sort(attribute='1', reverse=true)|slice(3) %}
|
||||
{{ code }} ({{ count }}){% if not loop.last %}, {% endif %}
|
||||
<p class="text-muted">
|
||||
{% if reservations %}
|
||||
{% set classroom_codes = [] %}
|
||||
{% for item in reservations %}
|
||||
{% if item.classroom.code not in classroom_codes %}
|
||||
{% set _ = classroom_codes.append(item.classroom.code) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for code in classroom_codes[:3] %}
|
||||
{{ code }}{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
No data available
|
||||
@@ -316,13 +313,13 @@
|
||||
<i class="bi bi-clock-fill text-primary" style="font-size: 2rem;"></i>
|
||||
</div>
|
||||
<h6>Total Hours Booked</h6>
|
||||
{% set total_minutes = 0 %}
|
||||
{% for item in reservations %}
|
||||
{% set duration = (item.reservation.end_time - item.reservation.start_time).total_seconds() / 60 %}
|
||||
{% set _ = total_minutes.__iadd__(duration) %}
|
||||
{% endfor %}
|
||||
<p class="text-muted">
|
||||
{{ (total_minutes / 60)|round(1) }} hours total
|
||||
<p class="text-muted">
|
||||
{% set total_hours = 0 %}
|
||||
{% for item in reservations %}
|
||||
{% set duration = (item.end_time - item.start_time).total_seconds() / 3600 %}
|
||||
{% set total_hours = (total_hours + duration) %}
|
||||
{% endfor %}
|
||||
{{ total_hours|round(1) }} hours total
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user