fix(classrooms): sincronizar salas virtuales con dashboard y dinamizar fechas (v3.8.10)

This commit is contained in:
2026-10-26 10:31:10 -03:00
parent e89f1b0457
commit 452ff8098a
10 changed files with 189 additions and 128 deletions
+17 -2
View File
@@ -394,6 +394,14 @@ class DashboardService:
)
comm_ids_virtual.update(comm_in_virtual_res)
res_map_comm_all: Dict[int, List[Reservation]] = {}
all_reservations_comm = Reservation.query.filter(
Reservation.commission_id.isnot(None)
).order_by(Reservation.start_time.asc()).all()
for r in all_reservations_comm:
if r.commission_id is not None:
res_map_comm_all.setdefault(int(r.commission_id), []).append(r)
virtual_rooms_data = []
for comm in all_active_commissions:
if comm.id in comm_ids_virtual:
@@ -401,10 +409,12 @@ class DashboardService:
res_tomorrow = res_map_comm_tomorrow.get(comm.id, [])
res_week = res_map_comm_week.get(comm.id, [])
res_month = res_map_comm_month.get(comm.id, [])
res_all = res_map_comm_all.get(comm.id, [])
v_link = comm.virtual_link or (res_today[0].virtual_link if res_today and res_today[0].virtual_link else '')
virtual_rooms_data.append({
'id': comm.id,
'commission_id': comm.id,
'commission_code': comm.code,
'code': comm.code,
'full_code': comm.get_full_code(),
'subject_name': comm.subject.name if comm.subject else 'Sin materia',
@@ -419,14 +429,19 @@ class DashboardService:
'is_virtual': True,
'building': 'Campus Virtual',
'floor': 'Remoto ∞',
'day_count': len(res_today),
'today_classes': len(res_today),
'tomorrow_classes': len(res_tomorrow),
'week_count': len(res_week),
'week_classes': len(res_week),
'month_count': len(res_month),
'month_classes': len(res_month),
'res_count': len(res_month),
'res_count': len(res_all) if len(res_all) > 0 else len(res_month),
'total_count': len(res_all),
'is_active_today': len(res_today) > 0,
'is_active_tomorrow': len(res_tomorrow) > 0,
'assigned_summary': f"{comm.subject.name if comm.subject else 'Clase Virtual'} ({comm.schedule or 'Remoto'})"
'assigned_summary': f"{comm.subject.name if comm.subject else 'Clase Virtual'} ({comm.schedule or 'Remoto'})",
'reservations': [self.serialize_reservation(r) for r in res_all]
})
if virtual_rooms_data: