VaneshDev commited on
Commit
813537d
·
verified ·
1 Parent(s): 3b90de1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -57,7 +57,7 @@ project_choices = [
57
  "Project Alpha", "Project Beta", "Project Gamma", "Project Delta", "Project Epsilon",
58
  "Project Zeta", "Project Theta", "Project Sigma", "Project Omega", "Project Phoenix"
59
  ]
60
- ai_suggestion_choices = ["Move", "Pause Rent", "Repair", "Replace"]
61
 
62
  def call_ai_model(usage, idle, freq, cost, last):
63
  try:
@@ -70,10 +70,8 @@ def call_ai_model(usage, idle, freq, cost, last):
70
  utilization_ratio = usage / total if total > 0 else 0.0
71
  utilization_percent = utilization_ratio * 100
72
 
73
- # Determine suggestion
74
- if utilization_percent < 30:
75
- sug = "Pause Rent"
76
- elif utilization_percent < 60:
77
  sug = "Move"
78
  elif utilization_percent < 80:
79
  sug = "Repair"
@@ -208,8 +206,6 @@ def format_output(result):
208
  f" • AI Suggestion: {summary.get('Suggestion', 'N/A')}",
209
  f" • Suggestion Confidence: {conf_pct:.2f}%",
210
  f" • Utilization Score: {util_score:.2f}%",
211
- # Report Link hidden from output
212
- # f" • Report Link: {result.get('Report_Link', 'N/A')}",
213
  f" • Equipment Name: {summary.get('Equipment Name', 'N/A')}",
214
  f" • Project: {summary.get('Project', 'N/A')}",
215
  f" • Usage Hours: {summary.get('Usage Hours', 0):.2f}",
@@ -252,7 +248,6 @@ def generate_batch_pdf(records, batch_uid):
252
  y = 760
253
 
254
  for idx, record in enumerate(records, 1):
255
- # Start new page if near bottom
256
  if y < 100:
257
  c.showPage()
258
  c.setFont("Helvetica-Bold", 14)
@@ -260,7 +255,6 @@ def generate_batch_pdf(records, batch_uid):
260
  c.setFont("Helvetica", 12)
261
  y = 750
262
 
263
- # Print title on first page or new page
264
  if y == 760:
265
  c.drawString(100, y, "Equipment Utilization Batch Report")
266
  y -= 20
@@ -314,7 +308,7 @@ def manual_input(equipment, project, usage, idle, freq, cost, last, ai_suggestio
314
  def batch_upload(csv_file):
315
  try:
316
  if csv_file is None:
317
- return "", None # Gracefully handle cleared or empty input
318
 
319
  df = pd.read_csv(csv_file.name)
320
 
@@ -343,7 +337,7 @@ def batch_upload(csv_file):
343
  df['last_maintenance'] = df['last_maintenance'].apply(lambda x: "N/A" if pd.isna(x) else str(x))
344
 
345
  if 'ai_suggestion' in df.columns:
346
- df['ai_suggestion'] = df['ai_suggestion'].fillna('') # Fix NaN -> empty string
347
  df['ai_suggestion'] = df['ai_suggestion'].apply(
348
  lambda x: x if x in ai_suggestion_choices else ''
349
  )
 
57
  "Project Alpha", "Project Beta", "Project Gamma", "Project Delta", "Project Epsilon",
58
  "Project Zeta", "Project Theta", "Project Sigma", "Project Omega", "Project Phoenix"
59
  ]
60
+ ai_suggestion_choices = ["Move", "Repair", "Replace"] # Removed "Pause Rent"
61
 
62
  def call_ai_model(usage, idle, freq, cost, last):
63
  try:
 
70
  utilization_ratio = usage / total if total > 0 else 0.0
71
  utilization_percent = utilization_ratio * 100
72
 
73
+ # Determine suggestion (no "Pause Rent")
74
+ if utilization_percent < 60:
 
 
75
  sug = "Move"
76
  elif utilization_percent < 80:
77
  sug = "Repair"
 
206
  f" • AI Suggestion: {summary.get('Suggestion', 'N/A')}",
207
  f" • Suggestion Confidence: {conf_pct:.2f}%",
208
  f" • Utilization Score: {util_score:.2f}%",
 
 
209
  f" • Equipment Name: {summary.get('Equipment Name', 'N/A')}",
210
  f" • Project: {summary.get('Project', 'N/A')}",
211
  f" • Usage Hours: {summary.get('Usage Hours', 0):.2f}",
 
248
  y = 760
249
 
250
  for idx, record in enumerate(records, 1):
 
251
  if y < 100:
252
  c.showPage()
253
  c.setFont("Helvetica-Bold", 14)
 
255
  c.setFont("Helvetica", 12)
256
  y = 750
257
 
 
258
  if y == 760:
259
  c.drawString(100, y, "Equipment Utilization Batch Report")
260
  y -= 20
 
308
  def batch_upload(csv_file):
309
  try:
310
  if csv_file is None:
311
+ return "", None
312
 
313
  df = pd.read_csv(csv_file.name)
314
 
 
337
  df['last_maintenance'] = df['last_maintenance'].apply(lambda x: "N/A" if pd.isna(x) else str(x))
338
 
339
  if 'ai_suggestion' in df.columns:
340
+ df['ai_suggestion'] = df['ai_suggestion'].fillna('')
341
  df['ai_suggestion'] = df['ai_suggestion'].apply(
342
  lambda x: x if x in ai_suggestion_choices else ''
343
  )