fix(admin): corregir tipo Literal[True] en filter() SQLAlchemy - separar condicion vb_id fuera del query
This commit is contained in:
@@ -1007,15 +1007,18 @@ def occupancy_metrics():
|
|||||||
vb = next((b for b in buildings if b.code == 'VIRTUAL' or 'virtual' in b.name.lower()), None)
|
vb = next((b for b in buildings if b.code == 'VIRTUAL' or 'virtual' in b.name.lower()), None)
|
||||||
vb_id = vb.id if vb else 0
|
vb_id = vb.id if vb else 0
|
||||||
|
|
||||||
physical_rooms = Classroom.query.filter(
|
_phys_q = Classroom.query.filter(
|
||||||
Classroom.is_active == True,
|
Classroom.is_active == True,
|
||||||
Classroom.building_id != vb_id if vb_id else True,
|
|
||||||
~Classroom.code.ilike('%VIRTUAL%')
|
~Classroom.code.ilike('%VIRTUAL%')
|
||||||
).all()
|
)
|
||||||
|
if vb_id:
|
||||||
|
_phys_q = _phys_q.filter(Classroom.building_id != vb_id)
|
||||||
|
physical_rooms = _phys_q.all()
|
||||||
|
|
||||||
vc = Classroom.query.filter(
|
if vb_id:
|
||||||
Classroom.building_id == vb_id if vb_id else Classroom.code.ilike('%VIRTUAL%')
|
vc = Classroom.query.filter(Classroom.building_id == vb_id).first()
|
||||||
).first()
|
else:
|
||||||
|
vc = Classroom.query.filter(Classroom.code.ilike('%VIRTUAL%')).first()
|
||||||
|
|
||||||
# Reservations in month
|
# Reservations in month
|
||||||
month_res = Reservation.query.filter(
|
month_res = Reservation.query.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user