Phase 3: fix login issue
This commit is contained in:
@@ -73,11 +73,10 @@ def index():
|
|||||||
).scalar()
|
).scalar()
|
||||||
|
|
||||||
# Recent inspections
|
# 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':
|
if current_user.role == 'inspector':
|
||||||
recent_inspections_query = recent_inspections_query.filter(Inspection.inspector_id == current_user.id)
|
recent_inspections_query = recent_inspections_query.filter(Inspection.inspector_id == current_user.id)
|
||||||
|
recent_inspections = recent_inspections_query.limit(5).all()
|
||||||
recent_inspections = recent_inspections_query.all()
|
|
||||||
|
|
||||||
# System statistics (admin/supervisor only)
|
# System statistics (admin/supervisor only)
|
||||||
total_facilities = Facility.query.filter_by(active=True).count() if current_user.role in ['admin', 'supervisor'] else 0
|
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,
|
completed=completed,
|
||||||
flagged=flagged,
|
flagged=flagged,
|
||||||
avg_score=round(float(avg_score), 2) if avg_score else None,
|
avg_score=round(float(avg_score), 2) if avg_score else None,
|
||||||
facility_scores=facility_scores,
|
facility_scores=[{'name': r.name, 'avg_score': round(float(r.avg_score), 2), 'count': r.count} for r in facility_scores],
|
||||||
daily_scores=daily_scores,
|
daily_scores=[{'day': str(r.day), 'avg': round(float(r.avg), 2), 'count': r.count} for r in daily_scores],
|
||||||
issue_severity=issue_severity,
|
issue_severity=[{'severity': r.severity, 'count': r.count} for r in issue_severity],
|
||||||
issue_status=issue_status,
|
issue_status=[{'status': r.status, 'count': r.count} for r in issue_status],
|
||||||
top_inspectors=top_inspectors,
|
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,
|
critical_issues=critical_issues,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -276,4 +276,4 @@ def export_issues():
|
|||||||
stream_with_context(generate()),
|
stream_with_context(generate()),
|
||||||
mimetype='text/csv',
|
mimetype='text/csv',
|
||||||
headers={'Content-Disposition': f'attachment; filename="{filename}"'}
|
headers={'Content-Disposition': f'attachment; filename="{filename}"'}
|
||||||
)
|
)
|
||||||
@@ -170,7 +170,6 @@ const BLUE = '#0d6efd', GREEN = '#198754', RED = '#dc3545',
|
|||||||
AMBER = '#ffc107', TEAL = '#0dcaf0', GRAY = '#adb5bd';
|
AMBER = '#ffc107', TEAL = '#0dcaf0', GRAY = '#adb5bd';
|
||||||
|
|
||||||
// ── Trend chart ──────────────────────────────────────────────────────────────
|
// ── Trend chart ──────────────────────────────────────────────────────────────
|
||||||
const trendData = {{ daily_scores | map(attribute=0) | list | tojson }}; {# dates #}
|
|
||||||
new Chart(document.getElementById('trendChart'), {
|
new Chart(document.getElementById('trendChart'), {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: {
|
data: {
|
||||||
@@ -239,4 +238,4 @@ new Chart(document.getElementById('statusChart'), {
|
|||||||
plugins: { legend: { position: 'bottom' } } }
|
plugins: { legend: { position: 'bottom' } } }
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user