Jul 17 - Fill the gaps between Single-tenant mode and Multi-tenant mode - MT4

This commit is contained in:
2026-07-17 11:36:05 -04:00
parent 253291d5a4
commit d44d761706
10 changed files with 565 additions and 19 deletions
+24
View File
@@ -344,8 +344,32 @@ def index():
.all()
)
# ── Scheduled inspections (phase43): upcoming / overdue ───────────────────
# Plan-mode only: 'auto' schedules materialise themselves into the
# inspections list, so surfacing them here would double-report the work.
sched_upcoming = []
sched_overdue_count = 0
if not is_customer:
from app.models.inspection_schedule import InspectionSchedule
_today = now_eastern().date()
_sq = InspectionSchedule.query.filter(
InspectionSchedule.active.is_(True),
InspectionSchedule.mode == 'plan',
)
if is_inspector:
_sq = _sq.filter(InspectionSchedule.inspector_id == current_user.id)
_all_sched = _sq.order_by(InspectionSchedule.next_run_at.asc()).all()
sched_overdue_count = sum(1 for s in _all_sched if s.is_overdue(_today))
# Upcoming = due today through the next 7 days (overdue shown separately)
sched_upcoming = [
s for s in _all_sched
if s.next_run_at and _today <= s.next_run_at.date() <= _today + timedelta(days=7)
][:8]
return render_template(
'dashboard.html',
sched_upcoming = sched_upcoming,
sched_overdue_count = sched_overdue_count,
today_inspections = today_inspections,
completed_today = completed_today,
open_issues = open_issues,