Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,7 +65,8 @@ def check_amc_reminders(df, current_date):
|
|
| 65 |
reminders = df[(df["days_to_amc"] >= 0) & (df["days_to_amc"] <= 30)][["device_id", "log_type", "status", "timestamp", "usage_hours", "downtime", "amc_date"]]
|
| 66 |
if reminders.empty:
|
| 67 |
return "No AMC reminders due within the next 30 days.", reminders
|
| 68 |
-
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
logging.error(f"AMC reminder generation failed: {str(e)}")
|
| 71 |
return f"AMC reminder generation failed: {str(e)}", pd.DataFrame()
|
|
@@ -321,6 +322,10 @@ async def process_logs(file_obj, lab_site_filter, equipment_type_filter, date_ra
|
|
| 321 |
if not file_obj:
|
| 322 |
return "No file uploaded.", pd.DataFrame(), None, '<p>No device cards available.</p>', None, None, None, None, "No anomalies detected.", "No AMC reminders.", "No insights generated.", None, last_modified_state, cached_df_state, None
|
| 323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
file_path = file_obj.name
|
| 325 |
current_modified_time = os.path.getmtime(file_path)
|
| 326 |
|
|
@@ -509,7 +514,7 @@ try:
|
|
| 509 |
insights_output = gr.Markdown()
|
| 510 |
with gr.Group(elem_classes="dashboard-section"):
|
| 511 |
gr.Markdown("### Export Report")
|
| 512 |
-
pdf_output = gr.File(label="Download
|
| 513 |
|
| 514 |
file_input.change(
|
| 515 |
fn=update_filters,
|
|
|
|
| 65 |
reminders = df[(df["days_to_amc"] >= 0) & (df["days_to_amc"] <= 30)][["device_id", "log_type", "status", "timestamp", "usage_hours", "downtime", "amc_date"]]
|
| 66 |
if reminders.empty:
|
| 67 |
return "No AMC reminders due within the next 30 days.", reminders
|
| 68 |
+
# Modified to show all reminders instead of limiting to 5
|
| 69 |
+
return "\n".join([f"- Device ID: {row['device_id']}, AMC Date: {row['amc_date']}" for _, row in reminders.iterrows()]), reminders
|
| 70 |
except Exception as e:
|
| 71 |
logging.error(f"AMC reminder generation failed: {str(e)}")
|
| 72 |
return f"AMC reminder generation failed: {str(e)}", pd.DataFrame()
|
|
|
|
| 322 |
if not file_obj:
|
| 323 |
return "No file uploaded.", pd.DataFrame(), None, '<p>No device cards available.</p>', None, None, None, None, "No anomalies detected.", "No AMC reminders.", "No insights generated.", None, last_modified_state, cached_df_state, None
|
| 324 |
|
| 325 |
+
# Check if date range is provided
|
| 326 |
+
if not date_range or len(date_range) != 2:
|
| 327 |
+
return "Please provide a valid date range.", pd.DataFrame(), None, '<p>No device cards available.</p>', None, None, None, None, "No anomalies detected.", "No AMC reminders.", "No insights generated.", None, last_modified_state, cached_df_state, None
|
| 328 |
+
|
| 329 |
file_path = file_obj.name
|
| 330 |
current_modified_time = os.path.getmtime(file_path)
|
| 331 |
|
|
|
|
| 514 |
insights_output = gr.Markdown()
|
| 515 |
with gr.Group(elem_classes="dashboard-section"):
|
| 516 |
gr.Markdown("### Export Report")
|
| 517 |
+
pdf_output = gr.File(label="Download Report as PDF")
|
| 518 |
|
| 519 |
file_input.change(
|
| 520 |
fn=update_filters,
|