Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -126,7 +126,7 @@ def create_salesforce_reports(df):
|
|
| 126 |
return "Cannot create reports: 'LabOps Reports' folder not found in Salesforce."
|
| 127 |
|
| 128 |
try:
|
| 129 |
-
# Usage Report
|
| 130 |
usage_report_metadata = {
|
| 131 |
"reportMetadata": {
|
| 132 |
"name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
|
@@ -136,19 +136,17 @@ def create_salesforce_reports(df):
|
|
| 136 |
{"column": "Status__c", "operator": "equals", "value": "Active"},
|
| 137 |
{"column": "Timestamp__c", "operator": "greaterOrEqual", "value": "THIS_MONTH"}
|
| 138 |
],
|
| 139 |
-
"
|
| 140 |
-
"Device_Id__c",
|
| 141 |
-
"Log_Type__c",
|
| 142 |
-
"Status__c",
|
| 143 |
-
"Timestamp__c",
|
| 144 |
-
"
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
{"column": "Usage_Hours__c", "aggregate": "Sum"},
|
| 148 |
-
{"column": "Downtime__c", "aggregate": "Sum"}
|
| 149 |
],
|
| 150 |
"groupingsDown": [
|
| 151 |
-
{"
|
| 152 |
],
|
| 153 |
"folderId": LABOPS_REPORTS_FOLDER_ID
|
| 154 |
}
|
|
@@ -157,7 +155,7 @@ def create_salesforce_reports(df):
|
|
| 157 |
usage_report_id = usage_result['id']
|
| 158 |
logging.info(f"Usage Report created: {usage_report_id}")
|
| 159 |
|
| 160 |
-
# AMC Reminders Report
|
| 161 |
amc_report_metadata = {
|
| 162 |
"reportMetadata": {
|
| 163 |
"name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
|
@@ -168,10 +166,10 @@ def create_salesforce_reports(df):
|
|
| 168 |
{"column": "AMC_Date__c", "operator": "greaterOrEqual", "value": "TODAY"},
|
| 169 |
{"column": "AMC_Date__c", "operator": "lessOrEqual", "value": "NEXT_N_DAYS:30"}
|
| 170 |
],
|
| 171 |
-
"
|
| 172 |
-
"Device_Id__c",
|
| 173 |
-
"AMC_Date__c",
|
| 174 |
-
"Status__c"
|
| 175 |
],
|
| 176 |
"folderId": LABOPS_REPORTS_FOLDER_ID
|
| 177 |
}
|
|
|
|
| 126 |
return "Cannot create reports: 'LabOps Reports' folder not found in Salesforce."
|
| 127 |
|
| 128 |
try:
|
| 129 |
+
# Usage Report (Summary Report)
|
| 130 |
usage_report_metadata = {
|
| 131 |
"reportMetadata": {
|
| 132 |
"name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
|
|
|
| 136 |
{"column": "Status__c", "operator": "equals", "value": "Active"},
|
| 137 |
{"column": "Timestamp__c", "operator": "greaterOrEqual", "value": "THIS_MONTH"}
|
| 138 |
],
|
| 139 |
+
"reportColumns": [
|
| 140 |
+
{"field": "Device_Id__c"},
|
| 141 |
+
{"field": "Log_Type__c"},
|
| 142 |
+
{"field": "Status__c"},
|
| 143 |
+
{"field": "Timestamp__c"},
|
| 144 |
+
{"field": "Usage_Hours__c", "aggregateTypes": ["Sum"]},
|
| 145 |
+
{"field": "Downtime__c", "aggregateTypes": ["Sum"]},
|
| 146 |
+
{"field": "AMC_Date__c"}
|
|
|
|
|
|
|
| 147 |
],
|
| 148 |
"groupingsDown": [
|
| 149 |
+
{"field": "Device_Id__c", "sortOrder": "Asc", "dateGranularity": "None"}
|
| 150 |
],
|
| 151 |
"folderId": LABOPS_REPORTS_FOLDER_ID
|
| 152 |
}
|
|
|
|
| 155 |
usage_report_id = usage_result['id']
|
| 156 |
logging.info(f"Usage Report created: {usage_report_id}")
|
| 157 |
|
| 158 |
+
# AMC Reminders Report (Tabular Report)
|
| 159 |
amc_report_metadata = {
|
| 160 |
"reportMetadata": {
|
| 161 |
"name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
|
|
|
| 166 |
{"column": "AMC_Date__c", "operator": "greaterOrEqual", "value": "TODAY"},
|
| 167 |
{"column": "AMC_Date__c", "operator": "lessOrEqual", "value": "NEXT_N_DAYS:30"}
|
| 168 |
],
|
| 169 |
+
"reportColumns": [
|
| 170 |
+
{"field": "Device_Id__c"},
|
| 171 |
+
{"field": "AMC_Date__c"},
|
| 172 |
+
{"field": "Status__c"}
|
| 173 |
],
|
| 174 |
"folderId": LABOPS_REPORTS_FOLDER_ID
|
| 175 |
}
|