Phase 3: fix login issue
This commit is contained in:
@@ -73,11 +73,10 @@ def index():
|
||||
).scalar()
|
||||
|
||||
# Recent inspections
|
||||
recent_inspections_query = Inspection.query.order_by(Inspection.inspection_date.desc()).limit(5)
|
||||
recent_inspections_query = Inspection.query.order_by(Inspection.inspection_date.desc())
|
||||
if current_user.role == 'inspector':
|
||||
recent_inspections_query = recent_inspections_query.filter(Inspection.inspector_id == current_user.id)
|
||||
|
||||
recent_inspections = recent_inspections_query.all()
|
||||
recent_inspections = recent_inspections_query.limit(5).all()
|
||||
|
||||
# System statistics (admin/supervisor only)
|
||||
total_facilities = Facility.query.filter_by(active=True).count() if current_user.role in ['admin', 'supervisor'] else 0
|
||||
|
||||
@@ -126,11 +126,11 @@ def index():
|
||||
completed=completed,
|
||||
flagged=flagged,
|
||||
avg_score=round(float(avg_score), 2) if avg_score else None,
|
||||
facility_scores=facility_scores,
|
||||
daily_scores=daily_scores,
|
||||
issue_severity=issue_severity,
|
||||
issue_status=issue_status,
|
||||
top_inspectors=top_inspectors,
|
||||
facility_scores=[{'name': r.name, 'avg_score': round(float(r.avg_score), 2), 'count': r.count} for r in facility_scores],
|
||||
daily_scores=[{'day': str(r.day), 'avg': round(float(r.avg), 2), 'count': r.count} for r in daily_scores],
|
||||
issue_severity=[{'severity': r.severity, 'count': r.count} for r in issue_severity],
|
||||
issue_status=[{'status': r.status, 'count': r.count} for r in issue_status],
|
||||
top_inspectors=[{'username': r.username, 'count': r.count, 'avg_score': round(float(r.avg_score), 2) if r.avg_score else None} for r in top_inspectors],
|
||||
critical_issues=critical_issues,
|
||||
)
|
||||
|
||||
|
||||
@@ -170,7 +170,6 @@ const BLUE = '#0d6efd', GREEN = '#198754', RED = '#dc3545',
|
||||
AMBER = '#ffc107', TEAL = '#0dcaf0', GRAY = '#adb5bd';
|
||||
|
||||
// ── Trend chart ──────────────────────────────────────────────────────────────
|
||||
const trendData = {{ daily_scores | map(attribute=0) | list | tojson }}; {# dates #}
|
||||
new Chart(document.getElementById('trendChart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user