Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,9 +107,13 @@ def forecast_labour(csv_file):
|
|
| 107 |
"expected_headcount": predictions[0]['headcount'],
|
| 108 |
"actual_headcount": int(df['Attendance'].iloc[-1]),
|
| 109 |
"Forecast_Next_3_Days__c": predictions,
|
| 110 |
-
"Project__c": "a01WU00000wklH4YAI" # Replace with valid Project ID
|
| 111 |
}
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
salesforce_record = {
|
| 114 |
'Trade__c': result_data['Trade'],
|
| 115 |
'Shortage_Risk__c': result_data['shortage_risk'],
|
|
@@ -117,12 +121,13 @@ def forecast_labour(csv_file):
|
|
| 117 |
'Expected_Headcount__c': result_data['expected_headcount'],
|
| 118 |
'Actual_Headcount__c': result_data['actual_headcount'],
|
| 119 |
'Forecast_Next_3_Days__c': str(result_data['Forecast_Next_3_Days__c']),
|
| 120 |
-
'Project_ID__c': result_data['Project__c'],
|
| 121 |
'Alert_Status__c': 'Normal',
|
| 122 |
'Dashboard_Display__c': True,
|
| 123 |
'Date__c': df['Date'].max().date().isoformat()
|
| 124 |
}
|
| 125 |
|
|
|
|
| 126 |
sf_result = save_to_salesforce(salesforce_record)
|
| 127 |
result_data.update(sf_result)
|
| 128 |
|
|
@@ -146,4 +151,4 @@ def gradio_interface():
|
|
| 146 |
).launch()
|
| 147 |
|
| 148 |
if __name__ == '__main__':
|
| 149 |
-
gradio_interface()
|
|
|
|
| 107 |
"expected_headcount": predictions[0]['headcount'],
|
| 108 |
"actual_headcount": int(df['Attendance'].iloc[-1]),
|
| 109 |
"Forecast_Next_3_Days__c": predictions,
|
| 110 |
+
"Project__c": "a01WU00000wklH4YAI" # Replace with valid Project ID (Check if this field exists or correct it)
|
| 111 |
}
|
| 112 |
|
| 113 |
+
# Check if 'Project__c' or the correct project field exists in Salesforce
|
| 114 |
+
if 'Project__c' not in result_data:
|
| 115 |
+
return {"error": "Invalid or missing field for 'Project__c'. Please ensure this field exists in Salesforce."}
|
| 116 |
+
|
| 117 |
salesforce_record = {
|
| 118 |
'Trade__c': result_data['Trade'],
|
| 119 |
'Shortage_Risk__c': result_data['shortage_risk'],
|
|
|
|
| 121 |
'Expected_Headcount__c': result_data['expected_headcount'],
|
| 122 |
'Actual_Headcount__c': result_data['actual_headcount'],
|
| 123 |
'Forecast_Next_3_Days__c': str(result_data['Forecast_Next_3_Days__c']),
|
| 124 |
+
'Project_ID__c': result_data['Project__c'], # Replace with correct field name if needed
|
| 125 |
'Alert_Status__c': 'Normal',
|
| 126 |
'Dashboard_Display__c': True,
|
| 127 |
'Date__c': df['Date'].max().date().isoformat()
|
| 128 |
}
|
| 129 |
|
| 130 |
+
# Attempt to save the record to Salesforce
|
| 131 |
sf_result = save_to_salesforce(salesforce_record)
|
| 132 |
result_data.update(sf_result)
|
| 133 |
|
|
|
|
| 151 |
).launch()
|
| 152 |
|
| 153 |
if __name__ == '__main__':
|
| 154 |
+
gradio_interface()
|