Overview
Incidents in Dashboard Backus represent operational delays that occur while a truck is in a bay. The system tracks incident duration and automatically deducts it from average yard time calculations, ensuring accurate performance metrics.Incidents are tracked per truck with a maximum limit of 3 incidents per truck. This limit enforces operational quality standards.
What Qualifies as an Incident?
Common incident types include:- Equipment failure: Forklift breakdown, loading system malfunction
- Documentation delays: Missing paperwork, signature approval wait times
- Quality issues: Product inspection holds, contamination checks
- Safety incidents: Emergency stops, evacuation protocols
- Coordination delays: Waiting for specific personnel, cross-dock dependencies
- Infrastructure problems: Bay door issues, lighting failures, spills
Incident Workflow
Incidents follow a two-step lifecycle:Opening an Incident
Identify Delay Event
Recognize that an unexpected delay has occurred or is about to occur for a truck currently in a bay.
Click '⚠️ Incid.' Button
Located at the bottom left of the occupied bay card, next to the ”✅ Salida” button.
Incident management is only available to Admin users.
Review Incident Modal
The Incident Management modal displays:
- Truck information: Plate, bay, product, operation, shift
- Incident counter: Visual slots showing 1/3, 2/3, or 3/3 incidents
- Active incident indicator: 🔴 pulsing dot if an incident is currently open
- Average incident duration: Mean time of all closed incidents for this truck
If no incidents are registered yet, counter shows three empty slots: [1] [2] [3]
Click '🔴 Abrir incidencia'
This button is:
- Enabled when:
- No incident is currently open (
hora_fin IS NOT NULLfor all incidents) - Incident count < 3
- No incident is currently open (
- Disabled when:
- An incident is already open (must close before opening new one)
- Incident limit reached (3/3)
Database Insert
The system performs an INSERT to the Fields:
incidencias table:id_incidencia: Auto-generated primary keyid_camion: Foreign key toviajes_camiones.id(integer)hora_inicio: Current time as “HH:MM:SS” (TIME type)hora_fin: NULL (will be set when incident is closed)duracion_calculada: NULL initially, calculated by Postgres trigger on UPDATE
Success toast: “⚠️ Incidencia 1/3 abierta — BFW-234”
Closing an Incident
Confirm Delay Resolved
Verify with yard staff that the incident cause has been resolved and normal operations have resumed.
Click '🟢 Cerrar incidencia'
This button is:
- Enabled when an incident is currently open
- Disabled when no incident is open
You can close an incident even if the truck has reached the 3-incident limit.
Database Update
The system performs an UPDATE to the Postgres Trigger: After the UPDATE, a database trigger calculates
incidencias table:duracion_calculada:Success toast: ”✅ Incidencia cerrada — BFW-234”
Incident Counter System
Visual Representation
The incident modal displays three slots:Incident Limit Enforcement
When a truck reaches 3 incidents: System Behavior:- ”🔴 Abrir incidencia” button is permanently disabled
- Red alert box appears in modal:
- Attempting to open an incident shows error toast:
- The truck can still be processed and exited normally
- No further incident time will be deducted from this truck’s yard time
The 3-incident limit is defined in
ModalIncidencia.tsx:21 as MAX_INCIDENCIAS = 3.Why the Limit Exists
The incident limit serves multiple purposes:- Quality control: Trucks with excessive incidents indicate systemic issues
- Data integrity: Prevents abuse or accidental over-registration
- Escalation trigger: Forces manual review by developers/management
- Performance accuracy: Excessive incidents could artificially inflate net time calculations
Time Deduction Mechanics
How Incident Time is Calculated
The system uses net yard time for performance metrics:Average Yard Time Panel
The “Average Yard Time” panel (left side of map) displays:vista_promedio_patio_neto Supabase view:
The green checkmark ”✓ incidencias descontadas” confirms that incident time has been automatically deducted.
Real-Time Incident Monitoring
Bay Card Indicator
When an incident is active:- 🔴 Pulsing dot appears next to the traffic light in the bay header
- Animation: CSS
pulsekeyframe (1 second cycle) - Tooltip: “Incidencia activa sin cerrar”
- Updates via polling every 8 seconds (
fetchIncidenciaAbierta())
The incident indicator is separate from the traffic light. A bay can show:
- 🟢 Green traffic light (short wait) + 🔴 Red incident dot (active incident)
- 🔴 Red traffic light (long wait) + no incident dot (no incidents)
Incident Modal Polling
While the incident modal is open, the system polls Supabase every 5 seconds for:- Incident count:
contarIncidencias(id_camion)- Total incidents (open + closed) - Open incident status:
fetchIncidenciaAbierta(id_camion)- Boolean for active incident - Average incident duration:
fetchPromedioIncidencias(id_camion)- Mean of closed incidents
Polling ensures the modal stays synchronized if another user opens/closes incidents for the same truck (multi-user scenario).
Common Incident Scenarios
Scenario 1: Equipment Failure Mid-Operation
Scenario 2: Documentation Hold
Scenario 3: Multiple Sequential Incidents
Best Practices
Open Incidents Immediately
Open Incidents Immediately
- Register incidents as soon as the delay is identified
- Don’t wait until the delay is resolved to open the incident
- Accurate start times ensure correct duration calculation
Close Incidents Promptly
Close Incidents Promptly
- Close incidents as soon as normal operations resume
- Do not leave incidents open “just in case” further delays occur
- If a new delay starts, open a new incident (up to the limit)
Monitor Incident Frequency
Monitor Incident Frequency
- Review incident counts across trucks to identify patterns
- High incident rates (>20% of trucks) indicate systemic issues
- Track which bays have frequent incidents (may need maintenance)
- Use session reports to analyze incident duration trends
Document Incident Causes
Document Incident Causes
- While the system doesn’t store incident descriptions, maintain a separate log
- Record incident type, cause, and resolution for post-shift review
- Use this data to inform process improvements and preventive maintenance
Handle Limit-Reached Trucks
Handle Limit-Reached Trucks
- Expedite processing for trucks at 3/3 incidents
- Investigate root causes with operations team
- Consider reassigning to a different bay if issues are bay-specific
- Document for management review and follow-up
Incident Data Structure
Database Schema
Table:incidencias
| Column | Type | Description |
|---|---|---|
id_incidencia | SERIAL | Primary key, auto-increment |
id_camion | INTEGER | Foreign key to viajes_camiones.id |
hora_inicio | TIME | Start time (HH:MM:SS), set when opened |
hora_fin | TIME | End time (HH:MM:SS), NULL when open |
duracion_calculada | INTERVAL | Auto-calculated on close: hora_fin - hora_inicio |
Example Records
Troubleshooting
Cannot Open Incident
Symptom: ”🔴 Abrir incidencia” button is disabled Possible Causes:- Incident already open: Close the current incident first
- Check for 🔴 pulsing dot in bay card
- Modal shows “Incidencia activa — sin hora de cierre”
- Incident limit reached: Truck has 3/3 incidents
- Modal shows red alert box
- Contact developers/management for guidance
Incident Not Closing
Symptom: Clicking ”🟢 Cerrar incidencia” shows loading but no success toast Possible Causes:- Network connection issue
- Database constraint violation
- No open incident exists (stale UI state)
- Check browser DevTools Network tab for failed request
- Close and reopen the modal to refresh data
- Verify in database that
hora_fin IS NULLfor an incident - Wait 5 seconds and retry
Incident Duration Not Deducted
Symptom: Average Yard Time panel doesn’t reflect incident deductions Possible Causes:- Incident not closed (still has
hora_fin = NULL) - Database trigger didn’t calculate
duracion_calculada - Truck not yet finalized (only finalized trucks count in average)
- Verify incident is closed (no 🔴 pulsing dot)
- Check database:
SELECT * FROM incidencias WHERE id_camion = 42; - Confirm truck has
estado = 'Finalizado' - Wait 15 seconds for panel polling to update
Incident Counter Incorrect
Symptom: Modal shows 2/3 but only 1 incident is visible in database Possible Causes:- Stale data from polling delay
- Multiple tabs/users modifying same truck
conteo_incidenciasfield inviajes_camionesout of sync
- Close and reopen modal to force refresh
- Verify actual count:
SELECT COUNT(*) FROM incidencias WHERE id_camion = 42; - If discrepancy persists, may need database trigger repair
Next Steps
Monitoring Operations
Learn how incident data affects real-time performance metrics
Generating Reports
Access detailed incident analytics in session reports
