# ❓ Why Are TAT Alerts Not Showing? ## 🎯 Follow These Steps IN ORDER ### ✅ Step 1: Is Redis Connected? **Check your backend console:** ``` Look for one of these messages: ``` **✅ GOOD (Redis is working):** ``` ✅ [TAT Queue] Connected to Redis ✅ [TAT Worker] Worker is ready and listening ``` **❌ BAD (Redis NOT working):** ``` ⚠️ [TAT Worker] Redis connection failed ⚠️ [TAT Queue] Redis connection failed after 3 attempts ``` **If you see the BAD message:** → **STOP HERE!** TAT alerts will NOT work without Redis! → **Setup Upstash Redis NOW:** 1. Go to: https://console.upstash.com/ 2. Sign up (free) 3. Create database 4. Copy Redis URL 5. Add to `Re_Backend/.env`: ```bash REDIS_URL=rediss://default:PASSWORD@host.upstash.io:6379 TAT_TEST_MODE=true ``` 6. Restart backend 7. Verify you see "Connected to Redis" --- ### ✅ Step 2: Have You Submitted a Request? **TAT monitoring starts ONLY when:** - ✅ Request is **SUBMITTED** (not just created/saved) - ✅ Status changes from DRAFT → PENDING **To verify:** ```sql SELECT request_number, status, submission_date FROM workflow_requests WHERE request_number = 'YOUR_REQUEST_NUMBER'; ``` **Check:** - `status` should be `PENDING`, `IN_PROGRESS`, or later - `submission_date` should NOT be NULL **If status is DRAFT:** → Click "Submit" button on the request → TAT monitoring will start --- ### ✅ Step 3: Has Enough Time Passed? **In TEST MODE (TAT_TEST_MODE=true):** - 1 hour = 1 minute - For 6-hour TAT: - 50% alert at: **3 minutes** - 75% alert at: **4.5 minutes** - 100% breach at: **6 minutes** **In PRODUCTION MODE:** - 1 hour = 1 hour (real time) - For 24-hour TAT: - 50% alert at: **12 hours** - 75% alert at: **18 hours** - 100% breach at: **24 hours** **Check when request was submitted:** ```sql SELECT request_number, submission_date, NOW() - submission_date as time_since_submission FROM workflow_requests WHERE request_number = 'YOUR_REQUEST_NUMBER'; ``` --- ### ✅ Step 4: Are Alerts in the Database? **Run this SQL:** ```sql -- Check if table exists SELECT COUNT(*) FROM tat_alerts; -- If table exists, check for your request SELECT ta.threshold_percentage, ta.alert_sent_at, ta.alert_message, ta.metadata FROM tat_alerts ta JOIN workflow_requests w ON ta.request_id = w.request_id WHERE w.request_number = 'YOUR_REQUEST_NUMBER' ORDER BY ta.alert_sent_at; ``` **Expected Result:** - **0 rows** → No alerts sent yet (wait longer OR Redis not connected) - **1+ rows** → Alerts exist! (Go to Step 5) **If table doesn't exist:** ```bash cd Re_Backend npm run migrate ``` --- ### ✅ Step 5: Is API Returning tatAlerts? **Test the API directly:** **Method 1: Use Debug Endpoint** ```bash curl http://localhost:5000/api/debug/workflow-details/YOUR_REQUEST_NUMBER ``` **Look for:** ```json { "structure": { "hasTatAlerts": true, ← Should be true "tatAlertsCount": 2 ← Should be > 0 }, "tatAlerts": [...] ← Should have data } ``` **Method 2: Check Network Tab in Browser** 1. Open Request Detail page 2. Open DevTools (F12) → Network tab 3. Find the API call to `/workflows/{requestNumber}/details` 4. Click on it 5. Check Response tab 6. Look for `tatAlerts` array --- ### ✅ Step 6: Is Frontend Receiving tatAlerts? **Open Browser Console (F12 → Console)** **When you open Request Detail, you should see:** ```javascript [RequestDetail] TAT Alerts received from API: 2 [Array(2)] ``` **If you see:** ```javascript [RequestDetail] TAT Alerts received from API: 0 [] ``` → API is NOT returning alerts (go back to Step 4) --- ### ✅ Step 7: Are Alerts Being Displayed? **In Request Detail:** 1. Click **"Workflow" tab** 2. Scroll to the approver card 3. Look under the approver's comment section **You should see yellow/orange/red boxes with:** ``` ⏳ Reminder 1 - 50% TAT Threshold ``` **If you DON'T see them:** → Check browser console for JavaScript errors --- ## 🔍 Quick Diagnostic **Run ALL of these and share the results:** ### 1. Backend Status: ```bash curl http://localhost:5000/api/debug/tat-status ``` ### 2. Database Query: ```sql SELECT COUNT(*) as total FROM tat_alerts; ``` ### 3. Browser Console: ```javascript // Open Request Detail // Check console for: [RequestDetail] TAT Alerts received from API: X [...] ``` ### 4. Network Response: ``` DevTools → Network → workflow details call → Response tab Look for "tatAlerts" field ``` --- ## 🎯 Most Likely Issues (In Order) ### 1. Redis Not Connected (90% of cases) **Symptom**: No "Connected to Redis" in logs **Fix**: Setup Upstash, add REDIS_URL, restart ### 2. Request Not Submitted (5%) **Symptom**: Request status is DRAFT **Fix**: Click Submit button ### 3. Not Enough Time Passed (3%) **Symptom**: Submitted < 3 minutes ago (in test mode) **Fix**: Wait 3 minutes for first alert ### 4. TAT Worker Not Running (1%) **Symptom**: Redis connected but no "Worker is ready" message **Fix**: Restart backend server ### 5. Frontend Code Not Applied (1%) **Symptom**: API returns tatAlerts but UI doesn't show them **Fix**: Refresh browser, clear cache --- ## 🚨 Emergency Checklist **Do this RIGHT NOW to verify everything:** ```bash # 1. Check backend console for Redis connection # Look for: ✅ [TAT Queue] Connected to Redis # 2. If NOT connected, setup Upstash: # https://console.upstash.com/ # 3. Add to .env: # REDIS_URL=rediss://... # TAT_TEST_MODE=true # 4. Restart backend npm run dev # 5. Check you see "Connected to Redis" # 6. Create NEW request with 6-hour TAT # 7. SUBMIT the request # 8. Wait 3 minutes # 9. Open browser console (F12) # 10. Open Request Detail page # 11. Check console log for: # [RequestDetail] TAT Alerts received from API: X [...] # 12. Go to Workflow tab # 13. Alerts should appear! ``` --- ## 📞 Share These for Help If still not working, share: 1. **Backend console output** (first 50 lines after starting) 2. **Result of**: `curl http://localhost:5000/api/debug/tat-status` 3. **SQL result**: `SELECT COUNT(*) FROM tat_alerts;` 4. **Browser console** when opening Request Detail 5. **Request number** you're testing with 6. **How long ago** was the request submitted? --- ## ✅ Working Example **When everything works, you'll see:** **Backend Console:** ``` ✅ [TAT Queue] Connected to Redis ✅ [TAT Worker] Worker is ready [TAT Scheduler] ✅ TAT jobs scheduled for request REQ-2025-001 ``` **After 3 minutes (test mode):** ``` [TAT Processor] Processing tat50 for request REQ-2025-001 [TAT Processor] TAT alert record created for tat50 [TAT Processor] tat50 notification sent ``` **Browser Console:** ```javascript [RequestDetail] TAT Alerts received from API: 1 [ { alertType: "TAT_50", thresholdPercentage: 50, alertSentAt: "2025-11-04T...", ... } ] ``` **UI Display:** ``` ⏳ Reminder 1 - 50% TAT Threshold 50% of SLA breach reminder have been sent ... ``` --- **Most likely you just need to setup Redis! See `START_HERE.md`** --- **Last Updated**: November 4, 2025