Spaces:
Sleeping
Sleeping
Update app.py
#1
by
sanjaybhargavneela1929
- opened
app.py
CHANGED
|
@@ -130,25 +130,46 @@ def create_salesforce_reports(df):
|
|
| 130 |
usage_report_metadata = {
|
| 131 |
"reportMetadata": {
|
| 132 |
"name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 133 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
"reportFormat": "SUMMARY",
|
|
|
|
| 135 |
"reportFilters": [
|
| 136 |
-
{
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
{
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
{"field": "AMC_Date__c"}
|
| 147 |
],
|
|
|
|
| 148 |
"groupingsDown": [
|
| 149 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
],
|
| 151 |
-
"folderId": LABOPS_REPORTS_FOLDER_ID
|
|
|
|
| 152 |
}
|
| 153 |
}
|
| 154 |
usage_result = sf.restful('analytics/reports', method='POST', json=usage_report_metadata)
|
|
@@ -159,19 +180,37 @@ def create_salesforce_reports(df):
|
|
| 159 |
amc_report_metadata = {
|
| 160 |
"reportMetadata": {
|
| 161 |
"name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 162 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
"reportFormat": "TABULAR",
|
|
|
|
| 164 |
"reportFilters": [
|
| 165 |
-
{
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
],
|
| 169 |
-
"
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
],
|
| 174 |
-
"folderId": LABOPS_REPORTS_FOLDER_ID
|
|
|
|
| 175 |
}
|
| 176 |
}
|
| 177 |
amc_result = sf.restful('analytics/reports', method='POST', json=amc_report_metadata)
|
|
|
|
| 130 |
usage_report_metadata = {
|
| 131 |
"reportMetadata": {
|
| 132 |
"name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 133 |
+
"developerName": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 134 |
+
"reportType": {
|
| 135 |
+
"type": "CustomObject",
|
| 136 |
+
"value": "SmartLog__c"
|
| 137 |
+
},
|
| 138 |
"reportFormat": "SUMMARY",
|
| 139 |
+
"reportBooleanFilter": None,
|
| 140 |
"reportFilters": [
|
| 141 |
+
{
|
| 142 |
+
"column": "SmartLog__c.Status__c",
|
| 143 |
+
"operator": "equals",
|
| 144 |
+
"value": "Active"
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"column": "SmartLog__c.Timestamp__c",
|
| 148 |
+
"operator": "greaterOrEqual",
|
| 149 |
+
"value": "THIS_MONTH"
|
| 150 |
+
}
|
|
|
|
| 151 |
],
|
| 152 |
+
"aggregates": ["s!SmartLog__c.Usage_Hours__c", "s!SmartLog__c.Downtime__c"],
|
| 153 |
"groupingsDown": [
|
| 154 |
+
{
|
| 155 |
+
"name": "Device_Id__c",
|
| 156 |
+
"field": "SmartLog__c.Device_Id__c",
|
| 157 |
+
"sortOrder": "Asc",
|
| 158 |
+
"sortAggregate": None,
|
| 159 |
+
"dateGranularity": "None"
|
| 160 |
+
}
|
| 161 |
+
],
|
| 162 |
+
"detailColumns": [
|
| 163 |
+
"SmartLog__c.Device_Id__c",
|
| 164 |
+
"SmartLog__c.Log_Type__c",
|
| 165 |
+
"SmartLog__c.Status__c",
|
| 166 |
+
"SmartLog__c.Timestamp__c",
|
| 167 |
+
"SmartLog__c.Usage_Hours__c",
|
| 168 |
+
"SmartLog__c.Downtime__c",
|
| 169 |
+
"SmartLog__c.AMC_Date__c"
|
| 170 |
],
|
| 171 |
+
"folderId": LABOPS_REPORTS_FOLDER_ID,
|
| 172 |
+
"currency": None
|
| 173 |
}
|
| 174 |
}
|
| 175 |
usage_result = sf.restful('analytics/reports', method='POST', json=usage_report_metadata)
|
|
|
|
| 180 |
amc_report_metadata = {
|
| 181 |
"reportMetadata": {
|
| 182 |
"name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 183 |
+
"developerName": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
|
| 184 |
+
"reportType": {
|
| 185 |
+
"type": "CustomObject",
|
| 186 |
+
"value": "SmartLog__c"
|
| 187 |
+
},
|
| 188 |
"reportFormat": "TABULAR",
|
| 189 |
+
"reportBooleanFilter": None,
|
| 190 |
"reportFilters": [
|
| 191 |
+
{
|
| 192 |
+
"column": "SmartLog__c.Status__c",
|
| 193 |
+
"operator": "equals",
|
| 194 |
+
"value": "Active"
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"column": "SmartLog__c.AMC_Date__c",
|
| 198 |
+
"operator": "greaterOrEqual",
|
| 199 |
+
"value": "TODAY"
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
"column": "SmartLog__c.AMC_Date__c",
|
| 203 |
+
"operator": "lessOrEqual",
|
| 204 |
+
"value": "NEXT_N_DAYS:30"
|
| 205 |
+
}
|
| 206 |
],
|
| 207 |
+
"detailColumns": [
|
| 208 |
+
"SmartLog__c.Device_Id__c",
|
| 209 |
+
"SmartLog__c.AMC_Date__c",
|
| 210 |
+
"SmartLog__c.Status__c"
|
| 211 |
],
|
| 212 |
+
"folderId": LABOPS_REPORTS_FOLDER_ID,
|
| 213 |
+
"currency": None
|
| 214 |
}
|
| 215 |
}
|
| 216 |
amc_result = sf.restful('analytics/reports', method='POST', json=amc_report_metadata)
|