Jul 15 - Update Dashboard - Add and switch Total This Week card
This commit is contained in:
@@ -34,6 +34,8 @@ def index():
|
||||
now = now_eastern()
|
||||
today_start = now.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
today_end = today_start + timedelta(days=1)
|
||||
# Start of the current week (Monday 00:00) for the "Submitted This Week" card.
|
||||
week_start = today_start - timedelta(days=today_start.weekday())
|
||||
|
||||
is_inspector = current_user.role == 'inspector'
|
||||
is_privileged = current_user.role in ['admin', 'director']
|
||||
@@ -61,14 +63,16 @@ def index():
|
||||
else:
|
||||
base_q = base_q.filter(Inspection.facility_id.in_(customer_facility_ids))
|
||||
|
||||
today_inspections = base_q.filter(
|
||||
completed_today = base_q.filter(
|
||||
Inspection.status == 'completed',
|
||||
Inspection.inspection_date >= today_start,
|
||||
Inspection.inspection_date < today_end,
|
||||
).count()
|
||||
|
||||
completed_today = base_q.filter(
|
||||
# Fully completed & submitted so far this week (Monday → now).
|
||||
submitted_this_week = base_q.filter(
|
||||
Inspection.status == 'completed',
|
||||
Inspection.inspection_date >= today_start,
|
||||
Inspection.inspection_date >= week_start,
|
||||
Inspection.inspection_date < today_end,
|
||||
).count()
|
||||
|
||||
@@ -375,7 +379,7 @@ def index():
|
||||
'dashboard.html',
|
||||
sched_upcoming = sched_upcoming,
|
||||
sched_overdue_count = sched_overdue_count,
|
||||
today_inspections = today_inspections,
|
||||
submitted_this_week = submitted_this_week,
|
||||
completed_today = completed_today,
|
||||
open_issues = open_issues,
|
||||
severity_breakdown = severity_breakdown,
|
||||
@@ -398,6 +402,7 @@ def index():
|
||||
customer_facilities = customer_facilities,
|
||||
my_issues = my_issues,
|
||||
today_str = now.strftime('%Y-%m-%d'),
|
||||
week_start_str = week_start.strftime('%Y-%m-%d'),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user