lokesh341 commited on
Commit
2606639
·
verified ·
1 Parent(s): ca02ee3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -5,6 +5,7 @@ from reportlab.pdfgen import canvas
5
  import base64
6
  import os
7
  import logging
 
8
  from datetime import datetime
9
  from fastapi.responses import HTMLResponse
10
  from simple_salesforce import Salesforce
@@ -231,12 +232,13 @@ async def get_dashboard():
231
  top_performing_logs = sorted_logs[:4] # Top 4 for "Top Performing Vendors" section
232
  alert_logs = [log for log in vendor_logs if determine_alert_flag(log['scores']['finalScore'], vendor_logs)]
233
 
 
234
  html_content = """
235
  <html>
236
  <head>
237
  <title>Subcontractor Performance Score App</title>
238
  <style>
239
- body { font-family: Arial, sans-serif; margin: 20px; background-color: #f5f7fa; }
240
  h1, h2 { color: #333; }
241
  .container { max-width: 1200px; margin: 0 auto; }
242
  .summary-cards { display: flex; gap: 20px; margin-bottom: 20px; }
@@ -314,7 +316,7 @@ async def get_dashboard():
314
  <td>#{idx}</td>
315
  <td>{log['vendorLogName']}</td>
316
  <td>{scores['finalScore']}</td>
317
- <td class="{trend}">{{"↗" if trend == "trend-up" else "↘" if trend == "trend-down" else "—"}}</td>
318
  <td><span class="{status_class}">{status_text}</span></td>
319
  </tr>
320
  """
@@ -433,7 +435,9 @@ async def get_dashboard():
433
  """
434
  return HTMLResponse(content=html_content)
435
  except Exception as e:
436
- logger.error(f"Error in / endpoint: {str(e)}")
 
 
437
  raise HTTPException(status_code=500, detail=f"Error generating dashboard: {str(e)}")
438
 
439
  if __name__ == "__main__":
 
5
  import base64
6
  import os
7
  import logging
8
+ import traceback
9
  from datetime import datetime
10
  from fastapi.responses import HTMLResponse
11
  from simple_salesforce import Salesforce
 
232
  top_performing_logs = sorted_logs[:4] # Top 4 for "Top Performing Vendors" section
233
  alert_logs = [log for log in vendor_logs if determine_alert_flag(log['scores']['finalScore'], vendor_logs)]
234
 
235
+ # HTML content for the dashboard
236
  html_content = """
237
  <html>
238
  <head>
239
  <title>Subcontractor Performance Score App</title>
240
  <style>
241
+ body { font-family: "Arial", sans-serif; margin: 20px; background-color: #f5f7fa; }
242
  h1, h2 { color: #333; }
243
  .container { max-width: 1200px; margin: 0 auto; }
244
  .summary-cards { display: flex; gap: 20px; margin-bottom: 20px; }
 
316
  <td>#{idx}</td>
317
  <td>{log['vendorLogName']}</td>
318
  <td>{scores['finalScore']}</td>
319
+ <td class="{trend}">{"↗" if trend == "trend-up" else "↘" if trend == "trend-down" else "—"}</td>
320
  <td><span class="{status_class}">{status_text}</span></td>
321
  </tr>
322
  """
 
435
  """
436
  return HTMLResponse(content=html_content)
437
  except Exception as e:
438
+ # Log the full stack trace for better debugging
439
+ error_trace = traceback.format_exc()
440
+ logger.error(f"Error in / endpoint: {str(e)}\nStack trace:\n{error_trace}")
441
  raise HTTPException(status_code=500, detail=f"Error generating dashboard: {str(e)}")
442
 
443
  if __name__ == "__main__":