Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,8 @@ picklist_mapping = {
|
|
| 93 |
'ops': 'UV Verification',
|
| 94 |
'maintenance': 'Smart Log',
|
| 95 |
'cell': 'Cell Analysis',
|
| 96 |
-
'uv': 'UV Verification'
|
|
|
|
| 97 |
}
|
| 98 |
}
|
| 99 |
|
|
@@ -200,11 +201,18 @@ def save_to_salesforce(df, summary, anomalies, amc_reminders, insights):
|
|
| 200 |
amc_date_str = None
|
| 201 |
if pd.notna(row['amc_date']):
|
| 202 |
try:
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
except Exception as e:
|
| 209 |
logging.error(f"Failed to parse AMC Date for Device ID {row['device_id']}: {str(e)}")
|
| 210 |
amc_date_str = None
|
|
|
|
| 93 |
'ops': 'UV Verification',
|
| 94 |
'maintenance': 'Smart Log',
|
| 95 |
'cell': 'Cell Analysis',
|
| 96 |
+
'uv': 'UV Verification',
|
| 97 |
+
'weight log': 'Smart Log' # Added mapping for 'weight log'
|
| 98 |
}
|
| 99 |
}
|
| 100 |
|
|
|
|
| 201 |
amc_date_str = None
|
| 202 |
if pd.notna(row['amc_date']):
|
| 203 |
try:
|
| 204 |
+
# Try parsing as DD-MM-YYYY
|
| 205 |
+
amc_date = pd.to_datetime(row['amc_date'], format='%d-%m-%Y', errors='coerce')
|
| 206 |
+
if pd.isna(amc_date):
|
| 207 |
+
# If that fails, try YYYY-MM-DD
|
| 208 |
+
amc_date = pd.to_datetime(row['amc_date'], format='%Y-%m-%d', errors='coerce')
|
| 209 |
+
if pd.isna(amc_date):
|
| 210 |
+
logging.error(f"Failed to parse AMC Date for Device ID {row['device_id']}: {row['amc_date']}")
|
| 211 |
+
else:
|
| 212 |
+
amc_date_str = amc_date.strftime('%Y-%m-%d')
|
| 213 |
+
amc_date_dt = datetime.strptime(amc_date_str, '%Y-%m-%d')
|
| 214 |
+
if status == "Active" and current_date.date() <= amc_date_dt.date() <= next_30_days.date():
|
| 215 |
+
logging.info(f"Record qualifies for AMC Reminders: Device ID {row['device_id']}, AMC Date {amc_date_str}")
|
| 216 |
except Exception as e:
|
| 217 |
logging.error(f"Failed to parse AMC Date for Device ID {row['device_id']}: {str(e)}")
|
| 218 |
amc_date_str = None
|