Fix 'Next shifts' when there are 'empty' rooms
This commit is contained in:
parent
337663e67c
commit
ea6f7d2849
|
@ -29,13 +29,16 @@ def shift_overview(request):
|
||||||
.order_by("start_at")
|
.order_by("start_at")
|
||||||
]
|
]
|
||||||
|
|
||||||
# probably can do some distinct/group by stuff but not sure how tih django queries
|
# only Postgres supports DISTINCT on specific columns, SQLite does not support aggregates on datetime fields
|
||||||
context["next_shifts"] = [
|
context["next_shifts"] = filter(
|
||||||
Shift.objects.filter(room=room, start_at__gt=timezone.now(), deleted=False)
|
lambda x: x is not None,
|
||||||
.order_by("start_at")
|
(
|
||||||
.first()
|
Shift.objects.filter(room=room, start_at__gt=timezone.now(), deleted=False)
|
||||||
for room in Room.objects.all()
|
.order_by("start_at")
|
||||||
]
|
.first()
|
||||||
|
for room in Room.objects.all()
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
return render(request, "shift_overview.html", context)
|
return render(request, "shift_overview.html", context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue